From 5bf367f90415c178669f4c0d7a9c9b9fbbcd601d Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 9 Oct 2023 00:16:06 +0200 Subject: Restore warning commit status (#27504) Partial revert of https://github.com/go-gitea/gitea/pull/25839. This commit status is used by a number of external integrations, so I think we should not remove it (See https://github.com/go-gitea/gitea/pull/25839#issuecomment-1729002077). This is a rare case where an existing migration needed to be alterted to avoid data loss. --------- Co-authored-by: delvh Co-authored-by: Giteabot --- modules/structs/commit_status.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'modules/structs') diff --git a/modules/structs/commit_status.go b/modules/structs/commit_status.go index fda795dca6..dc880ef5eb 100644 --- a/modules/structs/commit_status.go +++ b/modules/structs/commit_status.go @@ -16,13 +16,16 @@ 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" ) var commitStatusPriorities = map[CommitStatusState]int{ CommitStatusError: 0, CommitStatusFailure: 1, - CommitStatusPending: 2, - CommitStatusSuccess: 3, + CommitStatusWarning: 2, + CommitStatusPending: 3, + CommitStatusSuccess: 4, } func (css CommitStatusState) String() string { @@ -32,7 +35,7 @@ func (css CommitStatusState) String() string { // NoBetterThan returns true if this State is no better than the given State // This function only handles the states defined in CommitStatusPriorities func (css CommitStatusState) NoBetterThan(css2 CommitStatusState) bool { - // NoBetterThan only handles the 4 states above + // NoBetterThan only handles the 5 states above if _, exist := commitStatusPriorities[css]; !exist { return false } @@ -63,3 +66,8 @@ 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 +} -- cgit v1.2.3