fix: branch 못 알아낸 건 unknown으로 하기

This commit is contained in:
2021-11-26 19:11:50 +09:00
parent 9f049dcb18
commit 6b035f64d2
2 changed files with 9 additions and 6 deletions
+2 -2
View File
@@ -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);
+7 -4
View File
@@ -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);