Fix wildcard in middle of actionsglob/scaleUpTrigger.githubEvent.checkRun.names not working (#395)

actionsglob patterns like `foo-*-bar` was not correctly working. Tests and the implementation was enhanced to correctly support it.
This commit is contained in:
Yusuke Kuoka 2021-03-17 06:46:48 +09:00 committed by GitHub
parent 264cf494e3
commit 9b871567b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -65,7 +65,7 @@ func Match(pat string, s string) bool {
s = subs[1]
wildcardInHead = false
wildcardInHead = wildcardInTail
}
r := s == ""

View File

@ -195,4 +195,20 @@ func TestMatch(t *testing.T) {
Want: false,
})
})
t.Run("actions-*-metrics == actions-workflow-metrics", func(t *testing.T) {
run(t, testcase{
Pattern: "actions-*-metrics",
Target: "actions-workflow-metrics",
Want: true,
})
})
t.Run("!actions-*-metrics == actions-workflow-metrics", func(t *testing.T) {
run(t, testcase{
Pattern: "!actions-*-metrics",
Target: "actions-workflow-metrics",
Want: false,
})
})
}