mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 13:45:19 +00:00
e483220ea3
* RM unused struct * rename (*CommitStatus) loadRepo() -> loadAttributes() * move ToCommitStatus into its own file * use CommitStatusState instead of StatusState * move CombinedStatus convertion into convert package * let models.GetLatestCommitStatus use repoID direct and accept ListOptions * update swagger docs * fix tests * Fix swagger docs * rm page * fix swagger docs!!! * return json null * always return json * rename api.Status to api.CommitStatus * fix swagger docs * sec swagger fix
64 lines
2.2 KiB
Go
64 lines
2.2 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package structs
|
|
|
|
// CommitStatusState holds the state of a CommitStatus
|
|
// It can be "pending", "success", "error", "failure", and "warning"
|
|
type CommitStatusState string
|
|
|
|
const (
|
|
// CommitStatusPending is for when the CommitStatus is Pending
|
|
CommitStatusPending CommitStatusState = "pending"
|
|
// CommitStatusSuccess is for when the CommitStatus is Success
|
|
CommitStatusSuccess CommitStatusState = "success"
|
|
// CommitStatusError is for when the CommitStatus is Error
|
|
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"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
}
|
|
|
|
// IsPending represents if commit status state is pending
|
|
func (css CommitStatusState) IsPending() bool {
|
|
return css == CommitStatusPending
|
|
}
|
|
|
|
// IsSuccess represents if commit status state is success
|
|
func (css CommitStatusState) IsSuccess() bool {
|
|
return css == CommitStatusSuccess
|
|
}
|
|
|
|
// IsError represents if commit status state is error
|
|
func (css CommitStatusState) IsError() bool {
|
|
return css == CommitStatusError
|
|
}
|
|
|
|
// IsFailure represents if commit status state is failure
|
|
func (css CommitStatusState) IsFailure() bool {
|
|
return css == CommitStatusFailure
|
|
}
|
|
|
|
// IsWarning represents if commit status state is warning
|
|
func (css CommitStatusState) IsWarning() bool {
|
|
return css == CommitStatusWarning
|
|
}
|