Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #713, match branches with wildcard #715

Merged
merged 1 commit into from
Nov 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix for #713, match branches with wildcard
  • Loading branch information
bradrydzewski committed Nov 18, 2014
commit f15cc20b5dc29c15c639b2b2f06505ece41d580a
4 changes: 3 additions & 1 deletion plugin/condition/condition.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package condition

import (
"path/filepath"
"strings"
)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugin/condition/condition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down