@@ -25,7 +25,13 @@ type branch struct {
2525 name string
2626}
2727
28- const BRANCH_NAME_PREFIX = "refs/heads/"
28+ const (
29+ BRANCH_NAME_PREFIX = "refs/heads/"
30+ FEATURE_BRANCH_PATTERN = `feature/[^/]+/.*`
31+ FIX_BRANCH_PATTERN = `fix/[^/]+/.*`
32+ HOTFIX_BRANCH_PATTERN = `hotfix/v.*`
33+ RELEASE_BRANCH_PATTERN = `release/v.*`
34+ )
2935
3036// NewBranch creates a new branch definition
3137func NewBranch (name string ) Branch {
@@ -43,19 +49,19 @@ func BranchFromBranchName(name string) (b Branch, err error) {
4349 Debug (l.Fields {"branch" : b }).
4450 Error (err )
4551 }()
46- matched , err := regexp .Match (`feature/[^/]+/.*` , []byte (name ))
52+ matched , err := regexp .Match (FEATURE_BRANCH_PATTERN , []byte (name ))
4753 if matched && err == nil {
4854 return FeatureFromBranch (name )
4955 }
50- matched , err = regexp .Match (`fix/[^/]+/.*` , []byte (name ))
56+ matched , err = regexp .Match (FIX_BRANCH_PATTERN , []byte (name ))
5157 if matched && err == nil {
5258 return FixFromBranch (name )
5359 }
54- matched , err = regexp .Match (`hotfix/v.*` , []byte (name ))
60+ matched , err = regexp .Match (HOTFIX_BRANCH_PATTERN , []byte (name ))
5561 if matched && err == nil {
5662 return HotfixFromBranch (name )
5763 }
58- matched , err = regexp .Match (`release/v.*` , []byte (name ))
64+ matched , err = regexp .Match (RELEASE_BRANCH_PATTERN , []byte (name ))
5965 if matched && err == nil {
6066 return ReleaseFromBranch (name )
6167 }
0 commit comments