Skip to content

Commit fc0c63c

Browse files
committed
get rule by id after getting rule by name failed
1 parent 8d1f1c9 commit fc0c63c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

routers/web/repo/setting_protected_branch.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,13 @@ func SettingsProtectedBranchPost(ctx *context.Context) {
165165
return
166166
}
167167

168-
if f.RuleID > 0 {
169-
var err error
168+
var err error
169+
protectBranch, err = git_model.GetProtectedBranchRuleByName(ctx, ctx.Repo.Repository.ID, f.RuleName)
170+
if err != nil {
171+
ctx.ServerError("GetProtectedBranchRuleByName", err)
172+
return
173+
}
174+
if protectBranch == nil && f.RuleID > 0 {
170175
protectBranch, err = git_model.GetProtectedBranchRuleByID(ctx, ctx.Repo.Repository.ID, f.RuleID)
171176
if err != nil {
172177
ctx.ServerError("GetProtectedBranchRuleByID", err)
@@ -245,7 +250,7 @@ func SettingsProtectedBranchPost(ctx *context.Context) {
245250
protectBranch.UnprotectedFilePatterns = f.UnprotectedFilePatterns
246251
protectBranch.BlockOnOutdatedBranch = f.BlockOnOutdatedBranch
247252

248-
err := git_model.UpdateProtectBranch(ctx, ctx.Repo.Repository, protectBranch, git_model.WhitelistOptions{
253+
err = git_model.UpdateProtectBranch(ctx, ctx.Repo.Repository, protectBranch, git_model.WhitelistOptions{
249254
UserIDs: whitelistUsers,
250255
TeamIDs: whitelistTeams,
251256
MergeUserIDs: mergeWhitelistUsers,

0 commit comments

Comments
 (0)