Skip to content

Commit

Permalink
Fetch Git commit ID from .git/HEAD if available
Browse files Browse the repository at this point in the history
refs #9247
  • Loading branch information
Al2Klimov committed Sep 23, 2015
1 parent b693111 commit abcdc5a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions library/Icinga/Application/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ class Version
*/
public static function get()
{
if (false !== ($gitHead = @file_get_contents((
$gitDir = Icinga::app()->getBaseDir('.git')
) . DIRECTORY_SEPARATOR . 'HEAD'))) {
$matches = array();
if ((1 !== @preg_match('/(?<!.)ref:\s+(?P<gitCommitID>.+?)$/ms', $gitHead, $matches) || false !== (
$gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . $matches['gitCommitID'])
)) && 1 === @preg_match('/(?<!.)(?P<gitCommitID>[0-9a-f]+)$/ms', $gitHead, $matches)) {
return $matches;
}
}

if (false === ($appVersion = @file_get_contents(
Icinga::app()->getApplicationDir() . DIRECTORY_SEPARATOR . 'VERSION'
))) {
Expand Down

0 comments on commit abcdc5a

Please sign in to comment.