summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/services/delete_merged_branches_service.rb2
-rw-r--r--changelogs/unreleased/tc-delete-merged-protected-tags-fix.yml5
-rw-r--r--spec/services/delete_merged_branches_service_spec.rb8
3 files changed, 14 insertions, 1 deletions
diff --git a/app/services/delete_merged_branches_service.rb b/app/services/delete_merged_branches_service.rb
index 077268b2388..cb235a85daf 100644
--- a/app/services/delete_merged_branches_service.rb
+++ b/app/services/delete_merged_branches_service.rb
@@ -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)
diff --git a/changelogs/unreleased/tc-delete-merged-protected-tags-fix.yml b/changelogs/unreleased/tc-delete-merged-protected-tags-fix.yml
new file mode 100644
index 00000000000..5d5c39108b0
--- /dev/null
+++ b/changelogs/unreleased/tc-delete-merged-protected-tags-fix.yml
@@ -0,0 +1,5 @@
+---
+title: When deleting merged branches, ignore protected tags
+merge_request: 15252
+author:
+type: fixed
diff --git a/spec/services/delete_merged_branches_service_spec.rb b/spec/services/delete_merged_branches_service_spec.rb
index 5a9eb359ee1..0de02576203 100644
--- a/spec/services/delete_merged_branches_service_spec.rb
+++ b/spec/services/delete_merged_branches_service_spec.rb
@@ -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) }