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
92039dd6
Commit
92039dd6
authored
Feb 27, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Developers can merge MR if target branch is not protected
parent
33cd1ae9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
7 deletions
+20
-7
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+15
-1
app/models/ability.rb
app/models/ability.rb
+0
-1
app/services/git_push_service.rb
app/services/git_push_service.rb
+2
-2
app/views/merge_requests/show/_mr_accept.html.haml
app/views/merge_requests/show/_mr_accept.html.haml
+3
-3
No files found.
app/controllers/merge_requests_controller.rb
View file @
92039dd6
...
...
@@ -81,7 +81,8 @@ class MergeRequestsController < ProjectResourceController
end
def
automerge
return
access_denied!
unless
can?
(
current_user
,
:accept_mr
,
@project
)
return
access_denied!
unless
allowed_to_merge?
if
@merge_request
.
opened?
&&
@merge_request
.
can_be_merged?
@merge_request
.
should_remove_source_branch
=
params
[
:should_remove_source_branch
]
@merge_request
.
automerge!
(
current_user
)
...
...
@@ -143,5 +144,18 @@ class MergeRequestsController < ProjectResourceController
# or from cache if already merged
@commits
=
@merge_request
.
commits
@commits
=
CommitDecorator
.
decorate
(
@commits
)
@allowed_to_merge
=
allowed_to_merge?
@show_merge_controls
=
@merge_request
.
opened?
&&
@commits
.
any?
&&
@allowed_to_merge
end
def
allowed_to_merge?
action
=
if
project
.
protected_branch?
(
@merge_request
.
target_branch
)
:push_code_to_protected_branches
else
:push_code
end
can?
(
current_user
,
action
,
@project
)
end
end
app/models/ability.rb
View file @
92039dd6
...
...
@@ -91,7 +91,6 @@ class Ability
:admin_team_member
,
:admin_merge_request
,
:admin_note
,
:accept_mr
,
:admin_wiki
,
:admin_project
]
...
...
app/services/git_push_service.rb
View file @
92039dd6
...
...
@@ -19,6 +19,8 @@ class GitPushService
# Collect data for this git push
@push_data
=
post_receive_data
(
oldrev
,
newrev
,
ref
)
create_push_event
project
.
ensure_satellite_exists
project
.
discover_default_branch
...
...
@@ -27,8 +29,6 @@ class GitPushService
project
.
execute_hooks
(
@push_data
.
dup
)
project
.
execute_services
(
@push_data
.
dup
)
end
create_push_event
end
# This method provide a sample data
...
...
app/views/merge_requests/show/_mr_accept.html.haml
View file @
92039dd6
-
unless
can?
(
current_user
,
:accept_mr
,
@project
)
-
unless
@allowed_to_merge
.alert
%strong
Only masters can accept
MR
%strong
You don't have enough permissions to merge this
MR
-
if
@
merge_request
.
opened?
&&
@commits
.
any?
&&
can?
(
current_user
,
:accept_mr
,
@project
)
-
if
@
show_merge_controls
.automerge_widget.can_be_merged
{
style:
"display:none"
}
.alert.alert-success
%span
...
...
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