Commit f7e7e40d authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch 'tc-no-delete-protected-merged-branches' into 'master'

DeleteMergedBranchesService should not delete protected branches

Closes #34553

See merge request !12624
parents 75ac425c e0f106ae
......@@ -10,6 +10,8 @@ def execute
branches = { |branch| project.repository.merged_to_root_ref?(branch) }
# Prevent deletion of branches relevant to open merge requests
branches -= merge_request_branch_names
# Prevent deletion of protected branches
branches -= project.protected_branches.pluck(:name)
branches.each do |branch|, current_user).execute(branch)
title: Do not delete protected branches when deleting all merged branches
merge_request: 12624
......@@ -24,6 +24,14 @@
expect(project.repository.branch_names).to include('master')
it 'keeps protected branches' do
create(:protected_branch, project: project, name: 'improve/awesome')
expect(project.repository.branch_names).to include('improve/awesome')
context 'user without rights' do
let(:user) { create(:user) }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment