summaryrefslogtreecommitdiffstats
path: root/modules/structs/commit_status.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/structs/commit_status.go')
-rw-r--r--modules/structs/commit_status.go26
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
-}