mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-03 04:33:48 +00:00
Fix exclude path constraint behavior (#5042)
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
This commit is contained in:
parent
47e6d159d1
commit
8a432a6b83
2 changed files with 25 additions and 5 deletions
|
@ -388,14 +388,19 @@ func (c *Path) Includes(v []string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Excludes returns true if the string matches any of the exclude patterns.
|
||||
// Excludes returns true if all of the strings match any of the exclude patterns.
|
||||
func (c *Path) Excludes(v []string) bool {
|
||||
for _, pattern := range c.Exclude {
|
||||
for _, file := range v {
|
||||
for _, file := range v {
|
||||
matched := false
|
||||
for _, pattern := range c.Exclude {
|
||||
if ok, _ := doublestar.Match(pattern, file); ok {
|
||||
return true
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !matched {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -233,8 +233,23 @@ func TestConstraintList(t *testing.T) {
|
|||
{
|
||||
conf: "{ include: [ '*.md' ], exclude: [ CHANGELOG.md ] }",
|
||||
with: []string{"README.md", "CHANGELOG.md"},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
conf: "{ exclude: [ CHANGELOG.md ] }",
|
||||
with: []string{"README.md", "CHANGELOG.md"},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
conf: "{ exclude: [ CHANGELOG.md, docs/**/*.md ] }",
|
||||
with: []string{"docs/main.md", "CHANGELOG.md"},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
conf: "{ exclude: [ CHANGELOG.md, docs/**/*.md ] }",
|
||||
with: []string{"docs/main.md", "CHANGELOG.md", "README.md"},
|
||||
want: true,
|
||||
},
|
||||
// commit message ignore matches
|
||||
{
|
||||
conf: "{ include: [ README.md ], ignore_message: '[ALL]' }",
|
||||
|
|
Loading…
Reference in a new issue