Merge pull request #715 from bradrydzewski/master
fix for #713, match branches with wildcard
This commit is contained in:
commit
789435d06d
2 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package condition
|
package condition
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,7 +41,8 @@ func (c *Condition) MatchBranch(branch string) bool {
|
||||||
if c.AllBranches != nil && *c.AllBranches == true {
|
if c.AllBranches != nil && *c.AllBranches == true {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return c.Branch == branch
|
match, _ := filepath.Match(c.Branch, branch)
|
||||||
|
return match
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchOwner is a helper function that returns false
|
// MatchOwner is a helper function that returns false
|
||||||
|
|
|
@ -59,6 +59,12 @@ func Test_MatchBranch(t *testing.T) {
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("Branch should not match, expected %v, got %v", want, got)
|
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) {
|
func Test_MatchOwner(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue