mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-11 14:49:35 +02:00
Rename CommitStatusSummary to CombinedStatus
This commit is contained in:
21 files changed
+107
-103
No files matched your search
@@ -3,33 +3,33 @@
|
||||
|
||||
package commitstatus
|
||||
|
||||
// CombinedStatus represents the combined status of a commit.
|
||||
type CombinedStatus string
|
||||
// CombinedStatusState represents the combined status of a commit.
|
||||
type CombinedStatusState string
|
||||
|
||||
const (
|
||||
// CombinedStatusPending is for when the CombinedStatus is Pending
|
||||
CombinedStatusPending CombinedStatus = "pending"
|
||||
// CombinedStatusSuccess is for when the CombinedStatus is Success
|
||||
CombinedStatusSuccess CombinedStatus = "success"
|
||||
// CombinedStatusFailure is for when the CombinedStatus is Failure
|
||||
CombinedStatusFailure CombinedStatus = "failure"
|
||||
// CombinedStatusStatePending is for when the CombinedStatus is Pending
|
||||
CombinedStatusStatePending CombinedStatusState = "pending"
|
||||
// CombinedStatusStateSuccess is for when the CombinedStatus is Success
|
||||
CombinedStatusStateSuccess CombinedStatusState = "success"
|
||||
// CombinedStatusStateFailure is for when the CombinedStatus is Failure
|
||||
CombinedStatusStateFailure CombinedStatusState = "failure"
|
||||
)
|
||||
|
||||
func (cs CombinedStatus) String() string {
|
||||
func (cs CombinedStatusState) String() string {
|
||||
return string(cs)
|
||||
}
|
||||
|
||||
// IsPending represents if commit status state is pending
|
||||
func (cs CombinedStatus) IsPending() bool {
|
||||
return cs == CombinedStatusPending
|
||||
func (cs CombinedStatusState) IsPending() bool {
|
||||
return cs == CombinedStatusStatePending
|
||||
}
|
||||
|
||||
// IsSuccess represents if commit status state is success
|
||||
func (cs CombinedStatus) IsSuccess() bool {
|
||||
return cs == CombinedStatusSuccess
|
||||
func (cs CombinedStatusState) IsSuccess() bool {
|
||||
return cs == CombinedStatusStateSuccess
|
||||
}
|
||||
|
||||
// IsFailure represents if commit status state is failure
|
||||
func (cs CombinedStatus) IsFailure() bool {
|
||||
return cs == CombinedStatusFailure
|
||||
func (cs CombinedStatusState) IsFailure() bool {
|
||||
return cs == CombinedStatusStateFailure
|
||||
}
|
||||
@@ -57,19 +57,19 @@ type CommitStatusStates []CommitStatusState //nolint
|
||||
// > pending if there are no statuses or a context is pending
|
||||
// > success if the latest status for all contexts is success
|
||||
|
||||
func (css CommitStatusStates) Merge() CombinedStatus {
|
||||
func (css CommitStatusStates) Merge() CombinedStatusState {
|
||||
successCnt := 0
|
||||
for _, state := range css {
|
||||
switch {
|
||||
case state.IsError() || state.IsFailure():
|
||||
return CombinedStatusFailure
|
||||
return CombinedStatusStateFailure
|
||||
case state.IsPending():
|
||||
case state.IsSuccess() || state.IsWarning():
|
||||
successCnt++
|
||||
}
|
||||
}
|
||||
if successCnt > 0 && successCnt == len(css) {
|
||||
return CombinedStatusSuccess
|
||||
return CombinedStatusStateSuccess
|
||||
}
|
||||
return CombinedStatusPending
|
||||
return CombinedStatusStatePending
|
||||
}
|
||||
Reference in new issue
Block a user