commit 477cdcdec1e9b54c75818739b15a9db36c722991
parent e6a6a4edbe5b40ce45bc92c0c63406ebdb69384f
Author: Felicia Hummel <felicitus@felicitus.org>
Date: Tue, 16 Aug 2016 19:10:08 +0200
Added git commit strings to the version information, fixes #714
Diffstat:
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/PartKeepr/CoreBundle/Services/VersionService.php b/src/PartKeepr/CoreBundle/Services/VersionService.php
@@ -40,17 +40,43 @@ class VersionService
$this->remoteFileLoader = $remoteFileLoader;
if (PartKeeprVersion::PARTKEEPR_VERSION == '{V_GIT}') {
- $this->setVersion('GIT development version');
+ $this->setVersion('GIT development version Commit '. $this->extractGITCommit() . " Short Commit " . $this->extractShortGITCommit());
} else {
$this->setVersion(PartKeeprVersion::PARTKEEPR_VERSION);
}
}
+ /**
+ * Extracts the current commit from GIT.
+ * @return string
+ */
+ public function extractGITCommit () {
+ $result = shell_exec("git rev-parse HEAD");
+ return trim($result);
+ }
+
+ /**
+ * Extracts the current short commit from GIT.
+ * @return string
+ */
+ public function extractShortGITCommit () {
+ $result = shell_exec("git rev-parse --short HEAD");
+ return trim($result);
+ }
+
+ /**
+ * Sets the version string
+ * @param $version string The version
+ */
public function setVersion($version)
{
$this->version = $version;
}
+ /**
+ * Returns the current version string
+ * @return string The version
+ */
public function getVersion()
{
return $this->version;
@@ -68,9 +94,10 @@ class VersionService
*/
public function doVersionCheck()
{
- if ($this->getVersion() === '{V_GIT}') {
+ if (PartKeeprVersion::PARTKEEPR_VERSION === '{V_GIT}') {
return;
}
+
if (substr($this->getVersion(), 0, 17) === 'partkeepr-nightly') {
return;
}
@@ -94,6 +121,11 @@ class VersionService
}
}
+ /**
+ * Returns the latest version information from partkeepr.org
+ *
+ * @return array|bool
+ */
public function getLatestVersion()
{
$data = $this->remoteFileLoader->createLoader()->load($this->versionURI);