Skip to content

Commit 531e82f

Browse files
committed
Don't delete unrenamed protected branch
1 parent 800d01a commit 531e82f

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

models/git/branch.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,6 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to str
406406
if _, err = sess.ID(protectedBranch.ID).Cols("branch_name").Update(protectedBranch); err != nil {
407407
return err
408408
}
409-
} else {
410-
// Delete the old rule since the branch no longer exists and the target already has a rule
411-
if _, err = sess.ID(protectedBranch.ID).Delete(&ProtectedBranch{}); err != nil {
412-
return err
413-
}
414409
}
415410
} else {
416411
// some glob protect rules may match this branch

models/git/branch_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ func TestRenameBranchProtectedRuleConflict(t *testing.T) {
197197

198198
protectedDev, err := git_model.GetProtectedBranchRuleByName(t.Context(), repo1.ID, "dev")
199199
assert.NoError(t, err)
200-
assert.Nil(t, protectedDev)
200+
assert.NotNil(t, protectedDev)
201+
assert.Equal(t, "dev", protectedDev.RuleName)
201202

202203
protectedMainByID, err := git_model.GetProtectedBranchRuleByID(t.Context(), repo1.ID, pbMain.ID)
203204
assert.NoError(t, err)

0 commit comments

Comments
 (0)