From 9b871567b1213eee40b22ae6ea05341328cf8b2b Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Wed, 17 Mar 2021 06:46:48 +0900 Subject: [PATCH] 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. --- pkg/actionsglob/actionsglob.go | 2 +- pkg/actionsglob/match_test.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/actionsglob/actionsglob.go b/pkg/actionsglob/actionsglob.go index 7966de04..b3df8c34 100644 --- a/pkg/actionsglob/actionsglob.go +++ b/pkg/actionsglob/actionsglob.go @@ -65,7 +65,7 @@ func Match(pat string, s string) bool { s = subs[1] - wildcardInHead = false + wildcardInHead = wildcardInTail } r := s == "" diff --git a/pkg/actionsglob/match_test.go b/pkg/actionsglob/match_test.go index c273cf12..e8933e00 100644 --- a/pkg/actionsglob/match_test.go +++ b/pkg/actionsglob/match_test.go @@ -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, + }) + }) }