Use Combine as the function name to combine commit status as combined status

This commit is contained in:
Lunny Xiao
2025-05-25 17:49:11 -07:00
parent eb9fe87231
commit d77674673a
2 changed files with 3 additions and 4 deletions
+2 -2
View File
@@ -232,7 +232,7 @@ func CalcCombinedStatusState(statuses []*CommitStatus) commitstatus.CombinedStat
for _, status := range statuses {
states = append(states, status.State)
}
return states.CalcAsCombinedStatusState()
return states.Combine()
}
// CalcCombinedStatus returns combined status struct, the commit statuses should order by id desc
@@ -252,7 +252,7 @@ func CalcCombinedStatus(statuses []*CommitStatus) *CombinedStatus {
return &CombinedStatus{
RepoID: statuses[0].RepoID,
SHA: statuses[0].SHA,
State: states.CalcAsCombinedStatusState(),
State: states.Combine(),
TargetURL: targetURL,
}
}
+1 -2
View File
@@ -56,8 +56,7 @@ type CommitStatusStates []CommitStatusState //nolint
// > failure if any of the contexts report as error or failure
// > pending if there are no statuses or a context is pending
// > success if the latest status for all contexts is success
func (css CommitStatusStates) CalcAsCombinedStatusState() CombinedStatusState {
func (css CommitStatusStates) Combine() CombinedStatusState {
successCnt := 0
for _, state := range css {
switch {