Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
app/services/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
def
execute
raise
Gitlab
::
Access
::
AccessDeniedError
unless
can?
(
current_user
,
:push_code
,
project
)
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37438
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
branches
=
project
.
repository
.
branch_names
branches
=
branches
.
select
{
|
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
=
branches
.
reject
{
|
branch
|
ProtectedBranch
.
protected?
(
project
,
branch
)
}
branches
=
project
.
repository
.
merged_branch_names
# Prevent deletion of branches relevant to open merge requests
branches
-=
merge_request_branch_names
# Prevent deletion of protected branches
branches
=
branches
.
reject
{
|
branch
|
ProtectedBranch
.
protected?
(
project
,
branch
)
}
branches
.
each
do
|
branch
|
DeleteBranchService
.
new
(
project
,
current_user
).
execute
(
branch
)
end
branches
.
each
do
|
branch
|
DeleteBranchService
.
new
(
project
,
current_user
).
execute
(
branch
)
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