mirror of
https://github.com/go-gitea/gitea
synced 2024-11-25 04:22:46 +01:00
optimize loadGlob for protectedBranch
This commit is contained in:
parent
cbde69f6ee
commit
ccb2e12189
1 changed files with 6 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue