@@ -83,11 +83,13 @@ func GetPipelineRunAndBranchNameFromCancelComment(comment string) (string, strin
83
83
// by /test, /retest or /cancel to return branch name and pipelinerun name.
84
84
func getPipelineRunAndBranchNameFromComment (typeOfComment , comment string ) (string , string , error ) {
85
85
var prName , branchName string
86
- splitTest := strings .Split (comment , typeOfComment )
86
+ // avoid parsing error due to branch name contains /test, /retest or /cancel,
87
+ // here only split the first keyword and not split the later keywords.
88
+ splitTest := strings .SplitN (comment , typeOfComment , 2 )
87
89
88
90
// after the split get the second part of the typeOfComment (/test, /retest or /cancel)
89
91
// as second part can be branch name or pipelinerun name and branch name
90
- // ex: /test branch:nightly, /test prname branch:nightly
92
+ // ex: /test branch:nightly, /test prname branch:nightly, /test prname branch:nightly key=value
91
93
if splitTest [1 ] != "" && strings .Contains (splitTest [1 ], ":" ) {
92
94
branchData := strings .Split (splitTest [1 ], ":" )
93
95
@@ -108,7 +110,8 @@ func getPipelineRunAndBranchNameFromComment(typeOfComment, comment string) (stri
108
110
// ex: /test prname
109
111
getFirstLine := strings .Split (splitTest [1 ], "\n " )
110
112
// trim spaces
111
- prName = strings .TrimSpace (getFirstLine [0 ])
113
+ // adapt for the comment contains the key=value pair
114
+ prName = strings .Split (strings .TrimSpace (getFirstLine [0 ]), " " )[0 ]
112
115
}
113
116
return prName , branchName , nil
114
117
}
0 commit comments