Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 64b3731

Browse files
committed
Add special handling for master branch name
1 parent 4a219a0 commit 64b3731

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/php/libsdk/SDK/Config.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ public static function guessCurrentBranchName() : ?string
213213
if (is_numeric($major) && is_numeric($minor)) {
214214
$branch = "$major.$minor";
215215
}
216+
217+
/* Verify that we use an available branch name. Master has some
218+
version, but no dedicated series. For master, it rather
219+
makes sense to use master as branch name. */
220+
$git = trim(shell_exec("where git.exe"));
221+
if ($git) {
222+
$cmd = "\"$git\" branch";
223+
224+
$ret = trim(shell_exec($cmd));
225+
if (preg_match_all(",\*\s+master,", $ret) > 0) {
226+
$branch = "master";
227+
}
228+
}
216229
}
217230

218231
return $branch;
@@ -277,10 +290,10 @@ public static function getCurrentBranchData() : array
277290
}
278291
}
279292

280-
if (!$ret["stability"]) {
293+
if (!@$ret["stability"]) {
281294
throw new Exception("Failed to find config with stability '" . self::getCurrentStabilityName() . "'");
282295
}
283-
if (!$ret["crt"]) {
296+
if (!@$ret["crt"]) {
284297
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
285298
}
286299

0 commit comments

Comments
 (0)