Split complex if statements
This commit is contained in:
parent
abcdc5adb1
commit
d6cf6313b9
|
@ -15,14 +15,21 @@ class Version
|
||||||
*/
|
*/
|
||||||
public static function get()
|
public static function get()
|
||||||
{
|
{
|
||||||
if (false !== ($gitHead = @file_get_contents((
|
$gitDir = Icinga::app()->getBaseDir('.git');
|
||||||
$gitDir = Icinga::app()->getBaseDir('.git')
|
$gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . 'HEAD');
|
||||||
) . DIRECTORY_SEPARATOR . 'HEAD'))) {
|
if (false !== $gitHead) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if ((1 !== @preg_match('/(?<!.)ref:\s+(?P<gitCommitID>.+?)$/ms', $gitHead, $matches) || false !== (
|
if (@preg_match('/(?<!.)ref:\s+(.+?)$/ms', $gitHead, $matches)) {
|
||||||
$gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . $matches['gitCommitID'])
|
$gitCommitID = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . $matches[1]);
|
||||||
)) && 1 === @preg_match('/(?<!.)(?P<gitCommitID>[0-9a-f]+)$/ms', $gitHead, $matches)) {
|
} else {
|
||||||
return $matches;
|
$gitCommitID = $gitHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false !== $gitCommitID) {
|
||||||
|
$matches = array();
|
||||||
|
if (@preg_match('/(?<!.)(?P<gitCommitID>[0-9a-f]+)$/ms', $gitCommitID, $matches)) {
|
||||||
|
return $matches;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue