Commit ea4cf98c authored by Douwe Maan's avatar Douwe Maan

Merge branch 'tc-delete-merged-protected-tags-fix' into 'master'

When deleting merged branches, ignore protected tags

Closes #39732

See merge request gitlab-org/gitlab-ce!15252
parents de614b0e ca3c8685
...@@ -13,7 +13,7 @@ class DeleteMergedBranchesService < BaseService ...@@ -13,7 +13,7 @@ class DeleteMergedBranchesService < BaseService
# Prevent deletion of branches relevant to open merge requests # Prevent deletion of branches relevant to open merge requests
branches -= merge_request_branch_names branches -= merge_request_branch_names
# Prevent deletion of protected branches # 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| branches.each do |branch|
DeleteBranchService.new(project, current_user).execute(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 ...@@ -42,6 +42,14 @@ describe DeleteMergedBranchesService do
expect(project.repository.branch_names).to include('improve/awesome') expect(project.repository.branch_names).to include('improve/awesome')
end 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 context 'user without rights' do
let(:user) { create(:user) } 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