diff options
author | caicandong <50507092+CaiCandong@users.noreply.github.com> | 2023-07-21 16:24:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 16:24:36 +0800 |
commit | 840830b655a65c0763e3fd4bd0ced9256d2081a5 (patch) | |
tree | cb7ce50867f197eac04b735d57e15c45c43347b7 /modules/structs | |
parent | d57e55cd470ec737c8a9458f0ef96455e0c322ec (diff) | |
download | gitea-840830b655a65c0763e3fd4bd0ced9256d2081a5.tar.gz gitea-840830b655a65c0763e3fd4bd0ced9256d2081a5.zip |
Remove commit status running and warning to align GitHub (#25839)
Fix #25776. Close #25826.
In the discussion of #25776, @wolfogre's suggestion was to remove the
commit status of `running` and `warning` to keep it consistent with
github.
references:
-
https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#about-commit-statuses
## :warning: BREAKING :warning:
So the commit status of Gitea will be consistent with GitHub, only
`pending`, `success`, `error` and `failure`, while `warning` and
`running` are not supported anymore.
---------
Co-authored-by: Jason Song <i@wolfogre.com>
Diffstat (limited to 'modules/structs')
-rw-r--r-- | modules/structs/commit_status.go | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/modules/structs/commit_status.go b/modules/structs/commit_status.go index 7e3b629b7a..ff31f2d2ac 100644 --- a/modules/structs/commit_status.go +++ b/modules/structs/commit_status.go @@ -16,26 +16,17 @@ const ( CommitStatusError CommitStatusState = "error" // CommitStatusFailure is for when the CommitStatus is Failure CommitStatusFailure CommitStatusState = "failure" - // CommitStatusWarning is for when the CommitStatus is Warning - CommitStatusWarning CommitStatusState = "warning" - // CommitStatusRunning is for when the CommitStatus is Running - CommitStatusRunning CommitStatusState = "running" ) // NoBetterThan returns true if this State is no better than the given State func (css CommitStatusState) NoBetterThan(css2 CommitStatusState) bool { - switch css { - case CommitStatusError: - return true - case CommitStatusFailure: - return css2 != CommitStatusError - case CommitStatusWarning: - return css2 != CommitStatusError && css2 != CommitStatusFailure - case CommitStatusPending: - return css2 != CommitStatusError && css2 != CommitStatusFailure && css2 != CommitStatusWarning - default: - return css2 != CommitStatusError && css2 != CommitStatusFailure && css2 != CommitStatusWarning && css2 != CommitStatusPending + commitStatusPriorities := map[CommitStatusState]int{ + CommitStatusError: 0, + CommitStatusFailure: 1, + CommitStatusPending: 2, + CommitStatusSuccess: 3, } + return commitStatusPriorities[css] <= commitStatusPriorities[css2] } // IsPending represents if commit status state is pending @@ -57,8 +48,3 @@ func (css CommitStatusState) IsError() bool { func (css CommitStatusState) IsFailure() bool { return css == CommitStatusFailure } - -// IsWarning represents if commit status state is warning -func (css CommitStatusState) IsWarning() bool { - return css == CommitStatusWarning -} |