Skip to content

Commit

Permalink
Fetch version from constant
Browse files Browse the repository at this point in the history
refs #9247
  • Loading branch information
Al2Klimov committed Sep 24, 2015
1 parent 91377a4 commit cc4a475
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion application/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$Format:%H%d %ci$
$Format:%H %ci$
17 changes: 5 additions & 12 deletions library/Icinga/Application/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
class Version
{
const VERSION = '2.0.0-rc1';

/**
* Get the version of this instance of Icinga Web 2
*
Expand All @@ -28,6 +30,7 @@ public static function get()
if (false !== $gitCommitID) {
$matches = array();
if (@preg_match('/(?<!.)(?P<gitCommitID>[0-9a-f]+)$/ms', $gitCommitID, $matches)) {
$matches['appVersion'] = self::VERSION;
return $matches;
}
}
Expand All @@ -38,21 +41,11 @@ public static function get()
}

$matches = array();
if (! @preg_match('/^(?P<gitCommitID>\S+)(?: \((.+?)\))? (?P<gitCommitDate>\S+)/', $appVersion, $matches)) {
if (! @preg_match('/^(?P<gitCommitID>\w+) (?P<gitCommitDate>\S+)/', $appVersion, $matches)) {
return false;
}

if (array_key_exists(1, $matches)) {
$tagMatches = array();
foreach (explode(', ', $matches[1]) as $gitRef) {
if (@preg_match('/^tag: v(.+)/', $gitRef, $tagMatches)) {
$matches['appVersion'] = $tagMatches[1];
break;
}
}
unset($matches[1]);
}

$matches['appVersion'] = self::VERSION;
return $matches;
}
}

0 comments on commit cc4a475

Please sign in to comment.