|
|
@ -16,13 +16,16 @@ const ( |
|
|
|
CommitStatusError CommitStatusState = "error" |
|
|
|
CommitStatusError CommitStatusState = "error" |
|
|
|
// CommitStatusFailure is for when the CommitStatus is Failure
|
|
|
|
// CommitStatusFailure is for when the CommitStatus is Failure
|
|
|
|
CommitStatusFailure CommitStatusState = "failure" |
|
|
|
CommitStatusFailure CommitStatusState = "failure" |
|
|
|
|
|
|
|
// CommitStatusWarning is for when the CommitStatus is Warning
|
|
|
|
|
|
|
|
CommitStatusWarning CommitStatusState = "warning" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var commitStatusPriorities = map[CommitStatusState]int{ |
|
|
|
var commitStatusPriorities = map[CommitStatusState]int{ |
|
|
|
CommitStatusError: 0, |
|
|
|
CommitStatusError: 0, |
|
|
|
CommitStatusFailure: 1, |
|
|
|
CommitStatusFailure: 1, |
|
|
|
CommitStatusPending: 2, |
|
|
|
CommitStatusWarning: 2, |
|
|
|
CommitStatusSuccess: 3, |
|
|
|
CommitStatusPending: 3, |
|
|
|
|
|
|
|
CommitStatusSuccess: 4, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (css CommitStatusState) String() string { |
|
|
|
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
|
|
|
|
// NoBetterThan returns true if this State is no better than the given State
|
|
|
|
// This function only handles the states defined in CommitStatusPriorities
|
|
|
|
// This function only handles the states defined in CommitStatusPriorities
|
|
|
|
func (css CommitStatusState) NoBetterThan(css2 CommitStatusState) bool { |
|
|
|
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 { |
|
|
|
if _, exist := commitStatusPriorities[css]; !exist { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
@ -63,3 +66,8 @@ func (css CommitStatusState) IsError() bool { |
|
|
|
func (css CommitStatusState) IsFailure() bool { |
|
|
|
func (css CommitStatusState) IsFailure() bool { |
|
|
|
return css == CommitStatusFailure |
|
|
|
return css == CommitStatusFailure |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IsWarning represents if commit status state is warning
|
|
|
|
|
|
|
|
func (css CommitStatusState) IsWarning() bool { |
|
|
|
|
|
|
|
return css == CommitStatusWarning |
|
|
|
|
|
|
|
} |
|
|
|