Skip to content

Commit ab91252

Browse files
final tidy-ing
Signed-off-by: Tim Vaillancourt <[email protected]>
1 parent 05a1df0 commit ab91252

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/ci_workflow_gen.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,17 @@ func getGitRefSHA(ctx context.Context, url, branchOrTag string) (string, error)
249249
if len(fields) != 2 {
250250
continue
251251
}
252+
if fields[1] != branchOrTag && !strings.HasSuffix(fields[1], "/"+branchOrTag) {
253+
continue
254+
}
255+
256+
// git SHA1 hashes are 40 hex characters.
252257
sha := fields[0]
253-
if strings.Contains(fields[1], branchOrTag) {
254-
// git SHA1 hashes are 40 hex characters.
255-
match, err := regexp.MatchString(`^[a-zA-Z0-9]{40}$`, sha)
256-
if !match || err != nil {
257-
continue
258-
}
259-
return sha, nil
258+
match, err := regexp.MatchString(`^[a-zA-Z0-9]{40}$`, sha)
259+
if !match || err != nil {
260+
continue
260261
}
262+
return sha, nil
261263
}
262264
return "", fmt.Errorf("cannot parse output of 'git ls-remote' for %q", url)
263265
}

0 commit comments

Comments
 (0)