Skip to content

Commit ccb2e12

Browse files
committed
optimize loadGlob for protectedBranch
1 parent cbde69f commit ccb2e12

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

models/git/protected_branch.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,18 @@ func IsRuleNameSpecial(ruleName string) bool {
8383
}
8484

8585
func (protectBranch *ProtectedBranch) loadGlob() {
86-
if protectBranch.globRule == nil {
86+
if protectBranch.globRule == nil && !protectBranch.isPlainName {
87+
// detect if it is not glob
88+
if !IsRuleNameSpecial(protectBranch.RuleName) {
89+
protectBranch.isPlainName = true
90+
return
91+
}
8792
var err error
8893
protectBranch.globRule, err = glob.Compile(protectBranch.RuleName, '/')
8994
if err != nil {
9095
log.Warn("Invalid glob rule for ProtectedBranch[%d]: %s %v", protectBranch.ID, protectBranch.RuleName, err)
9196
protectBranch.globRule = glob.MustCompile(glob.QuoteMeta(protectBranch.RuleName), '/')
9297
}
93-
protectBranch.isPlainName = !IsRuleNameSpecial(protectBranch.RuleName)
9498
}
9599
}
96100

0 commit comments

Comments
 (0)