Skip to content

Commit

Permalink
Fixing the issue when status check per rule matches multiple actions. (
Browse files Browse the repository at this point in the history
  • Loading branch information
charles7668 committed Mar 7, 2024
1 parent 4527748 commit 6b0a767
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions services/pull/commit_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,30 @@ 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++
break
}
}

// If required rule not match any action, then it is pending
if targetStatus == "" {
if structs.CommitStatusPending.NoBetterThan(returnedStatus) {
returnedStatus = structs.CommitStatusPending
}
break
}

if targetStatus != "" && targetStatus.NoBetterThan(returnedStatus) {
returnedStatus = targetStatus
}
}
}

if matchedCount != len(requiredContexts) {
return structs.CommitStatusPending
}

if matchedCount == 0 {
status := git_model.CalcCommitStatus(commitStatuses)
if status != nil {
Expand Down

0 comments on commit 6b0a767

Please sign in to comment.