Fixing the issue when status check per rule matches multiple actions (#29631)
Close #29628 rule ``` Test / Build* Test / Build * Test / Build 2* Test / Build 1* ```  rule2 ``` Test / Build* Test / Build 1* ```  rule3 ``` Test / Build* Test / Build 1* NotExist* ```  --------- Co-authored-by: Zettat123 <zettat123@gmail.com> (cherry picked from commit 7cf7a499be80931ae34588201e9605085898e9b8)
This commit is contained in:
parent
76db6d9e74
commit
ac2e882dbf
2 changed files with 76 additions and 7 deletions
|
@ -36,9 +36,9 @@ func MergeRequiredContextsCommitStatus(commitStatuses []*git_model.CommitStatus,
|
|||
}
|
||||
}
|
||||
|
||||
for _, commitStatus := range commitStatuses {
|
||||
for _, gp := range requiredContextsGlob {
|
||||
var targetStatus structs.CommitStatusState
|
||||
for _, gp := range requiredContextsGlob {
|
||||
for _, commitStatus := range commitStatuses {
|
||||
if gp.Match(commitStatus.Context) {
|
||||
targetStatus = commitStatus.State
|
||||
matchedCount++
|
||||
|
@ -46,16 +46,20 @@ func MergeRequiredContextsCommitStatus(commitStatuses []*git_model.CommitStatus,
|
|||
}
|
||||
}
|
||||
|
||||
if targetStatus != "" && targetStatus.NoBetterThan(returnedStatus) {
|
||||
// If required rule not match any action, then it is pending
|
||||
if targetStatus == "" {
|
||||
if structs.CommitStatusPending.NoBetterThan(returnedStatus) {
|
||||
returnedStatus = structs.CommitStatusPending
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if targetStatus.NoBetterThan(returnedStatus) {
|
||||
returnedStatus = targetStatus
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if matchedCount != len(requiredContexts) {
|
||||
return structs.CommitStatusPending
|
||||
}
|
||||
|
||||
if matchedCount == 0 {
|
||||
status := git_model.CalcCommitStatus(commitStatuses)
|
||||
if status != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue