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
iv
gitlab-ce
Commits
0455391a
Commit
0455391a
authored
May 22, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve branch-removal logic
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
e089b11b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
app/controllers/projects/branches_controller.rb
app/controllers/projects/branches_controller.rb
+2
-7
app/services/delete_branch_service.rb
app/services/delete_branch_service.rb
+4
-0
app/views/projects/branches/_branch.html.haml
app/views/projects/branches/_branch.html.haml
+2
-2
No files found.
app/controllers/projects/branches_controller.rb
View file @
0455391a
...
...
@@ -4,8 +4,7 @@ class Projects::BranchesController < Projects::ApplicationController
before_filter
:require_non_empty_project
before_filter
:authorize_code_access!
before_filter
:authorize_push!
,
only:
[
:create
]
before_filter
:authorize_admin_project!
,
only:
[
:destroy
]
before_filter
:authorize_push!
,
only:
[
:create
,
:destroy
]
def
index
@branches
=
Kaminari
.
paginate_array
(
@repository
.
branches
).
page
(
params
[
:page
]).
per
(
30
)
...
...
@@ -22,11 +21,7 @@ class Projects::BranchesController < Projects::ApplicationController
end
def
destroy
branch
=
@repository
.
find_branch
(
params
[
:id
])
if
branch
&&
@repository
.
rm_branch
(
branch
.
name
)
Event
.
create_ref_event
(
@project
,
current_user
,
branch
,
'rm'
)
end
DeleteBranchService
.
new
.
execute
(
project
,
params
[
:id
],
current_user
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
project_branches_path
(
@project
)
}
...
...
app/services/delete_branch_service.rb
View file @
0455391a
...
...
@@ -8,6 +8,10 @@ class DeleteBranchService
return
error
(
'No such branch'
)
end
if
branch_name
==
repository
.
root_ref
return
error
(
'Cannot remove HEAD branch'
)
end
# Dont allow remove of protected branch
if
project
.
protected_branch?
(
branch_name
)
return
error
(
'Protected branch cant be removed'
)
...
...
app/views/projects/branches/_branch.html.haml
View file @
0455391a
...
...
@@ -16,8 +16,8 @@
%i
.icon-copy
Compare
-
if
can
?
(
current_user
,
:admin_project
,
@project
)
&&
branch
.
name
!=
@repository
.
root_ref
=
link_to
project_branch_path
(
@project
,
branch
.
name
),
class:
'btn btn-grouped btn-small remove-row'
,
method: :delete
,
data:
{
confirm:
'Removed branch cannot be restored. Are you sure?'
},
remote:
true
do
-
if
can
_remove_branch?
(
@project
,
branch
.
name
)
=
link_to
project_branch_path
(
@project
,
branch
.
name
),
class:
'btn btn-grouped btn-small
btn-remove
remove-row'
,
method: :delete
,
data:
{
confirm:
'Removed branch cannot be restored. Are you sure?'
},
remote:
true
do
%i
.icon-trash
-
if
commit
...
...
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