diff --git a/hwe/sammo/VersionGitDynamic.php b/hwe/sammo/VersionGitDynamic.php index bd8642a4..ec19dd29 100644 --- a/hwe/sammo/VersionGitDynamic.php +++ b/hwe/sammo/VersionGitDynamic.php @@ -17,8 +17,8 @@ class VersionGitDynamic $command = 'git branch --contains HEAD'; exec($command, $output); if (is_array($output)) { - if (count($output)) { - $output = Util::array_last($output); + if (count($output) > 1) { + $output = $output[1]; $output = trim($output, " \t\n\r\0\x0b*"); $output = explode('/', $output); $versionTokens[] = Util::array_last($output); diff --git a/j_updateServer.php b/j_updateServer.php index 3fd1585a..50ed0f47 100644 --- a/j_updateServer.php +++ b/j_updateServer.php @@ -9,6 +9,9 @@ set_time_limit(600); function getVersion($target = null) { $versionTokens = []; + if ($target) { + $target = trim($target); + } if ($target) { $command = sprintf('git describe %s --long --tags', escapeshellarg($target)); @@ -21,14 +24,14 @@ function getVersion($target = null) } if ($target) { - $command = sprintf('git branch --contains %s', escapeshellarg($target)); + $command = sprintf('git branch -a --contains %s', escapeshellarg($target)); } else { - $command = 'git branch --contains HEAD'; + $command = 'git branch -a --contains HEAD'; } exec($command, $output); if (is_array($output)) { - if (count($output)) { - $output = Util::array_last($output); + if (count($output) > 1) { + $output = $output[1]; $output = trim($output, " \t\n\r\0\x0b*"); $output = explode('/', $output); $versionTokens[] = Util::array_last($output);