BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
50749135
Commit
50749135
authored
Feb 12, 2018
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove allow_n_plus_1 block from DeleteMergedBranchesService
Fixes #37438 Fixes gitaly#999
parent
80c1626b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
delete_merged_branches_service.rb
app/services/delete_merged_branches_service.rb
+7
-11
No files found.
app/services/delete_merged_branches_service.rb
View file @
50749135
...
@@ -6,18 +6,14 @@ class DeleteMergedBranchesService < BaseService
...
@@ -6,18 +6,14 @@ class DeleteMergedBranchesService < BaseService
def
execute
def
execute
raise
Gitlab
::
Access
::
AccessDeniedError
unless
can?
(
current_user
,
:push_code
,
project
)
raise
Gitlab
::
Access
::
AccessDeniedError
unless
can?
(
current_user
,
:push_code
,
project
)
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37438
branches
=
project
.
repository
.
merged_branch_names
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
# Prevent deletion of branches relevant to open merge requests
branches
=
project
.
repository
.
branch_names
branches
-=
merge_request_branch_names
branches
=
branches
.
select
{
|
branch
|
project
.
repository
.
merged_to_root_ref?
(
branch
)
}
# Prevent deletion of protected branches
# Prevent deletion of branches relevant to open merge requests
branches
=
branches
.
reject
{
|
branch
|
ProtectedBranch
.
protected?
(
project
,
branch
)
}
branches
-=
merge_request_branch_names
# Prevent deletion of protected branches
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
)
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment