Commit ca3c8685 authored by Toon Claes's avatar Toon Claes

When deleting merged branches, ignore protected tags

In gitlab-org/gitlab-ce!13251 wildcard Protected Branches were handled
properly when deleting all merged branches. But this fix wasn't that
good. It also checked branch names against Protected Tags. That's not
correct.

This change will **only** check if there is a Protected Branch
matching the merged branch, and ignores Protected Tags.

Closes gitlab-org/gitlab-ce#39732.
parent dc1e6b43
......@@ -13,7 +13,7 @@ class DeleteMergedBranchesService < BaseService
# Prevent deletion of branches relevant to open merge requests
branches -= merge_request_branch_names
# Prevent deletion of protected branches
branches = branches.reject { |branch| project.protected_for?(branch) }
branches = branches.reject { |branch| ProtectedBranch.protected?(project, branch) }
branches.each do |branch|
DeleteBranchService.new(project, current_user).execute(branch)
......
---
title: When deleting merged branches, ignore protected tags
merge_request: 15252
author:
type: fixed
......@@ -42,6 +42,14 @@ describe DeleteMergedBranchesService do
expect(project.repository.branch_names).to include('improve/awesome')
end
it 'ignores protected tags' do
create(:protected_tag, project: project, name: 'improve/*')
service.execute
expect(project.repository.branch_names).not_to include('improve/awesome')
end
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