You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-07-12 22:21:40 +02:00
Rework status constraint logic for successes (#1515)
Since "success" and "failure" are the only two possible values, and "success" is considered to be included by default, the existing code can also be simplified a little. This has the side effect of ignoring the "exclude" part of the constraint completely. I put it in the tests just to make sure the workaround in https://github.com/woodpecker-ci/woodpecker/issues/1181#issuecomment-1347253585 continues to work as expected, but couldn't think of any legitimate use cases for it. Fixes #1181
This commit is contained in:
@ -79,9 +79,9 @@ func (when *When) Match(metadata frontend.Metadata, global bool) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (when *When) IncludesStatus(status string) bool {
|
||||
func (when *When) IncludesStatusFailure() bool {
|
||||
for _, c := range when.Constraints {
|
||||
if c.Status.Includes(status) {
|
||||
if c.Status.Includes("failure") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -89,14 +89,19 @@ func (when *When) IncludesStatus(status string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (when *When) ExcludesStatus(status string) bool {
|
||||
func (when *When) IncludesStatusSuccess() bool {
|
||||
// "success" acts differently than "failure" in that it's
|
||||
// presumed to be included unless it's specifically not part
|
||||
// of the list
|
||||
if when.IsEmpty() {
|
||||
return true
|
||||
}
|
||||
for _, c := range when.Constraints {
|
||||
if !c.Status.Excludes(status) {
|
||||
return false
|
||||
if len(c.Status.Include) == 0 || c.Status.Includes("success") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return len(when.Constraints) > 0
|
||||
return false
|
||||
}
|
||||
|
||||
// False if (any) non local
|
||||
|
Reference in New Issue
Block a user