Version::get(): first try to parse application/VERSION

refs #9247
This commit is contained in:
Alexander A. Klimov 2015-06-05 12:38:55 +02:00
parent cc4a47506f
commit 3e99adbe63
1 changed files with 9 additions and 11 deletions

View File

@ -17,6 +17,14 @@ class Version
*/ */
public static function get() public static function get()
{ {
if (false !== ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('VERSION')))) {
$matches = array();
if (@preg_match('/^(?P<gitCommitID>\w+) (?P<gitCommitDate>\S+)/', $appVersion, $matches)) {
$matches['appVersion'] = self::VERSION;
return $matches;
}
}
$gitDir = Icinga::app()->getBaseDir('.git'); $gitDir = Icinga::app()->getBaseDir('.git');
$gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . 'HEAD'); $gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . 'HEAD');
if (false !== $gitHead) { if (false !== $gitHead) {
@ -36,16 +44,6 @@ class Version
} }
} }
if (false === ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('VERSION')))) { return false;
return false;
}
$matches = array();
if (! @preg_match('/^(?P<gitCommitID>\w+) (?P<gitCommitDate>\S+)/', $appVersion, $matches)) {
return false;
}
$matches['appVersion'] = self::VERSION;
return $matches;
} }
} }