From 576640e661f205f673662af68b24033df8a91e78 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 9 Sep 2016 14:19:32 +0200 Subject: [PATCH] Simplify Version::getGitHead() refs #11664 --- library/Icinga/Application/Version.php | 32 ++++++++++---------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 0565c3bf5..264fe5065 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -34,35 +34,27 @@ class Version } /** - * Get the hexadecimal ID of the HEAD commit of the Git repository in $repoDir + * Get the current commit of the Git repository in the given path * - * @param string $repoDir - * @param bool $bare Whether the repository has been created with - * $ git init|clone --bare + * @param string $repo Path to the Git repository + * @param bool $bare Whether the Git repository is bare * - * @return string|bool false if not available + * @return string|bool False if not available */ - public static function getGitHead($repoDir, $bare = false) + public static function getGitHead($repo, $bare = false) { if (! $bare) { - $repoDir .= DIRECTORY_SEPARATOR . '.git'; + $repo .= '/.git'; } - $gitHead = @ file_get_contents($repoDir . DIRECTORY_SEPARATOR . 'HEAD'); - if ($gitHead !== false) { - $matches = array(); - if (preg_match('/(?