Skip to content

Commit 6ca5640

Browse files
committed
fix(circleci-orb): do not cut off branch names with slashes
1 parent 953a36a commit 6ca5640

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

circleci-orb/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
22

33
ORB_NAME = "angular/dev-infra"
44

5-
ORB_VERSION = "1.0.1"
5+
ORB_VERSION = "1.0.2"
66

77
nodejs_binary(
88
name = "pack_orb_script",

circleci-orb/scripts/rebase-pr-on-target-branch/ref-branch-list.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ const semverRegex = /^(\d+)\.(\d+)\.x$/;
2020
* likely correct branch will be the first one encountered in the list.
2121
*/
2222
export function getRefFromBranchList(gitOutput: string, primaryBranchName: string): string {
23-
const branches = gitOutput.split(/\r?\n/g).map((b) => b.split('/').slice(1).join('').trim());
23+
const branches = gitOutput.split(/\r?\n/g).map((b) => {
24+
// Omit the leading remote name. e.g. my_remote/fix/whatever -> fix/whatever.
25+
return b.split('/').slice(1).join('/').trim();
26+
});
2427

25-
return branches.sort((a: string, b: string) => {
28+
const sorted = branches.sort((a: string, b: string) => {
2629
if (a === primaryBranchName) {
2730
return -1;
2831
}
@@ -51,5 +54,10 @@ export function getRefFromBranchList(gitOutput: string, primaryBranchName: strin
5154
}
5255

5356
return 0;
54-
})[0];
57+
});
58+
59+
if (sorted.length === 0) {
60+
throw new Error(`Could not find ref from branch list: ${gitOutput}`);
61+
}
62+
return sorted[0];
5563
}

0 commit comments

Comments
 (0)