From f15cc20b5dc29c15c639b2b2f06505ece41d580a Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Tue, 18 Nov 2014 14:09:30 -0800 Subject: [PATCH] fix for #713, match branches with wildcard --- plugin/condition/condition.go | 4 +++- plugin/condition/condition_test.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugin/condition/condition.go b/plugin/condition/condition.go index 9a6bc2a7..c7266b48 100644 --- a/plugin/condition/condition.go +++ b/plugin/condition/condition.go @@ -1,6 +1,7 @@ package condition import ( + "path/filepath" "strings" ) @@ -40,7 +41,8 @@ func (c *Condition) MatchBranch(branch string) bool { if c.AllBranches != nil && *c.AllBranches == true { return true } - return c.Branch == branch + match, _ := filepath.Match(c.Branch, branch) + return match } // MatchOwner is a helper function that returns false diff --git a/plugin/condition/condition_test.go b/plugin/condition/condition_test.go index 8a007e15..e9a8c1ca 100644 --- a/plugin/condition/condition_test.go +++ b/plugin/condition/condition_test.go @@ -59,6 +59,12 @@ func Test_MatchBranch(t *testing.T) { if got != want { t.Errorf("Branch should not match, expected %v, got %v", want, got) } + + c.Branch = "release/*" + got, want = c.MatchBranch("release/1.0.0"), true + if got != want { + t.Errorf("Branch should match wildcard, expected %v, got %v", want, got) + } } func Test_MatchOwner(t *testing.T) {