mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-04 11:30:51 +09:00
Update Combine method to treat warnings as failures and adjust tests (#37048)
Treat Commit Status Warnings as errors > The root problem is that the definition of "warning" are different across systems. > > * Sometimes, "warning" is treated as "acceptable" (Gitea 1.25) > * Sometimes, "warning" is mapped from "Result.UNSTABLE", which means "there are test failures" and it is "failure" in Gitea > > **To avoid breaking existing users, the best choice is to revert the behavior on Gitea side: treat "warning" as "error".** https://github.com/go-gitea/gitea/issues/37042#issuecomment-4158231611 fixes https://github.com/go-gitea/gitea/issues/37042 --------- Signed-off-by: Nicolas <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -61,16 +61,17 @@ type CommitStatusStates []CommitStatusState //nolint:revive // export stutter
|
||||
// According to https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#get-the-combined-status-for-a-specific-reference
|
||||
// > Additionally, a combined state is returned. The state is one of:
|
||||
// > failure if any of the contexts report as error or failure
|
||||
// > failure if any of the contexts report as warning (Gitea specific behavior)
|
||||
// > pending if there are no statuses or a context is pending
|
||||
// > success if the latest status for all contexts is success
|
||||
func (css CommitStatusStates) Combine() CommitStatusState {
|
||||
successCnt := 0
|
||||
for _, state := range css {
|
||||
switch {
|
||||
case state.IsError() || state.IsFailure():
|
||||
case state.IsError() || state.IsFailure() || state.IsWarning():
|
||||
return CommitStatusFailure
|
||||
case state.IsPending():
|
||||
case state.IsSuccess() || state.IsWarning() || state.IsSkipped():
|
||||
case state.IsSuccess() || state.IsSkipped():
|
||||
successCnt++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user