Skip to content

Commit e48931a

Browse files
mathur07zakisk
authored andcommitted
fix(gitops-commands): parse branch vs tag by 'tag:'
Use strings.Contains(..., "tag:") instead of "tag" when deciding between tag and branch in /retest comment parsing. Branch names like akurlov/ROX-32966-test-tagged-rebuild were mis-parsed as tag, leaving branchName empty and causing 'SHA is not the HEAD of master' on commit comments. SRVKP-10915 Signed-off-by: Shubham Mathur <shumathu@redhat.com>
1 parent a227d9f commit e48931a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pkg/provider/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func getPipelineRunAndBranchOrTagNameFromComment(typeOfComment, comment string)
139139
return prName, branchName, tagName, fmt.Errorf("the GitOps comment `%s` does not contain a branch or tag word", comment)
140140
}
141141

142-
if strings.Contains(splitText[1], "tag") {
142+
if strings.Contains(splitText[1], "tag:") {
143143
tagName = getBranchOrTagNameFromComment(splitText[1], "tag")
144144
} else {
145145
branchName = getBranchOrTagNameFromComment(splitText[1], "branch")

pkg/provider/provider_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ func TestGetPipelineRunAndBranchNameFromTestComment(t *testing.T) {
333333
branchName: "chore/test",
334334
wantError: false,
335335
},
336+
{
337+
name: "branch name contains substring tag so not parsed as tag",
338+
comment: "/retest my-pipeline branch:feature-test-tagged-release",
339+
prName: "my-pipeline",
340+
branchName: "feature-test-tagged-release",
341+
wantError: false,
342+
},
336343
{
337344
name: "different word other than branch for retest command",
338345
comment: "/retest invalidname:nightly",

0 commit comments

Comments
 (0)