diff --git a/models/git/protected_branch.go b/models/git/protected_branch.go index bde6057375e5..70033476247c 100644 --- a/models/git/protected_branch.go +++ b/models/git/protected_branch.go @@ -83,14 +83,18 @@ func IsRuleNameSpecial(ruleName string) bool { } func (protectBranch *ProtectedBranch) loadGlob() { - if protectBranch.globRule == nil { + if protectBranch.globRule == nil && !protectBranch.isPlainName { + // detect if it is not glob + if !IsRuleNameSpecial(protectBranch.RuleName) { + protectBranch.isPlainName = true + return + } 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), '/') } - protectBranch.isPlainName = !IsRuleNameSpecial(protectBranch.RuleName) } }