@ -84,14 +84,20 @@ func IsRuleNameSpecial(ruleName string) bool {
}
}
func ( protectBranch * ProtectedBranch ) loadGlob ( ) {
func ( protectBranch * ProtectedBranch ) loadGlob ( ) {
if protectBranch . globRule == nil {
if protectBranch . isPlainName || protectBranch . globRule != nil {
var err error
return
protectBranch . globRule , err = glob . Compile ( protectBranch . RuleName , '/' )
}
if err != nil {
// detect if it is not glob
log . Warn ( "Invalid glob rule for ProtectedBranch[%d]: %s %v" , protectBranch . ID , protectBranch . RuleName , err )
if ! IsRuleNameSpecial ( protectBranch . RuleName ) {
protectBranch . globRule = glob . MustCompile ( glob . QuoteMeta ( protectBranch . RuleName ) , '/' )
protectBranch . isPlainName = true
}
return
protectBranch . isPlainName = ! IsRuleNameSpecial ( protectBranch . RuleName )
}
// now we load the glob
var err error
protectBranch . globRule , err = glob . Compile ( protectBranch . RuleName , '/' )
if err != nil {
log . Warn ( "Invalid glob rule for ProtectedBranch[%d]: %s %v" , protectBranch . ID , protectBranch . RuleName , err )
protectBranch . globRule = glob . MustCompile ( glob . QuoteMeta ( protectBranch . RuleName ) , '/' )
}
}
}
}