Skip to content

Commit 7653326

Browse files
committed
Fixing the issue when status check per rule matches multiple actions. (#29628)
1 parent c1331d1 commit 7653326

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

services/pull/commit_status.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,30 @@ func MergeRequiredContextsCommitStatus(commitStatuses []*git_model.CommitStatus,
3535
}
3636
}
3737

38-
for _, commitStatus := range commitStatuses {
38+
for _, gp := range requiredContextsGlob {
3939
var targetStatus structs.CommitStatusState
40-
for _, gp := range requiredContextsGlob {
40+
for _, commitStatus := range commitStatuses {
4141
if gp.Match(commitStatus.Context) {
4242
targetStatus = commitStatus.State
4343
matchedCount++
4444
break
4545
}
4646
}
4747

48+
// If required rule not match any action, then it is pending
49+
if targetStatus == "" {
50+
if structs.CommitStatusPending.NoBetterThan(returnedStatus) {
51+
returnedStatus = structs.CommitStatusPending
52+
}
53+
break
54+
}
55+
4856
if targetStatus != "" && targetStatus.NoBetterThan(returnedStatus) {
4957
returnedStatus = targetStatus
5058
}
5159
}
5260
}
5361

54-
if matchedCount != len(requiredContexts) {
55-
return structs.CommitStatusPending
56-
}
57-
5862
if matchedCount == 0 {
5963
status := git_model.CalcCommitStatus(commitStatuses)
6064
if status != nil {

0 commit comments

Comments
 (0)