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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
946b4ced
Commit
946b4ced
authored
Jun 11, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve variables in mr widget
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
8893ac4b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
15 deletions
+8
-15
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-12
app/models/merge_request.rb
app/models/merge_request.rb
+4
-0
app/views/projects/merge_requests/widget/_open.html.haml
app/views/projects/merge_requests/widget/_open.html.haml
+1
-1
app/views/projects/merge_requests/widget/open/_conflicts.html.haml
.../projects/merge_requests/widget/open/_conflicts.html.haml
+1
-1
app/views/projects/merge_requests/widget/open/_wip.html.haml
app/views/projects/merge_requests/widget/open/_wip.html.haml
+1
-1
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
946b4ced
...
...
@@ -139,14 +139,13 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request
.
check_if_can_be_merged
end
@allowed_to_merge
=
allowed_to_merge?
closes_issues
render
partial:
"projects/merge_requests/widget/show.html.haml"
,
layout:
false
end
def
automerge
return
access_denied!
unless
allowed_to_merge?
return
access_denied!
unless
@merge_request
.
can_be_merged_by?
(
current_user
)
if
@merge_request
.
automergeable?
AutoMergeWorker
.
perform_async
(
@merge_request
.
id
,
current_user
.
id
,
params
)
...
...
@@ -255,8 +254,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@commits
=
@merge_request
.
commits
@merge_request_diff
=
@merge_request
.
merge_request_diff
@allowed_to_merge
=
allowed_to_merge?
@show_merge_controls
=
@merge_request
.
open?
&&
@commits
.
any?
&&
@allowed_to_merge
@source_branch
=
@merge_request
.
source_project
.
repository
.
find_branch
(
@merge_request
.
source_branch
).
try
(
:name
)
if
@merge_request
.
locked_long_ago?
...
...
@@ -265,19 +262,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
allowed_to_merge?
allowed_to_push_code?
(
project
,
@merge_request
.
target_branch
)
end
def
invalid_mr
# Render special view for MR with removed source or target branch
render
'invalid'
end
def
allowed_to_push_code?
(
project
,
branch
)
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
).
can_push_to_branch?
(
branch
)
end
def
merge_request_params
params
.
require
(
:merge_request
).
permit
(
:title
,
:assignee_id
,
:source_project_id
,
:source_branch
,
...
...
app/models/merge_request.rb
View file @
946b4ced
...
...
@@ -413,4 +413,8 @@ class MergeRequest < ActiveRecord::Base
def
branch_missing?
!
source_branch_exists?
||
!
target_branch_exists?
end
def
can_be_merged_by?
(
user
)
::
Gitlab
::
GitAccess
.
new
(
user
,
project
).
can_push_to_branch?
(
target_branch
)
end
end
app/views/projects/merge_requests/widget/_open.html.haml
View file @
946b4ced
...
...
@@ -15,7 +15,7 @@
=
render
'projects/merge_requests/widget/open/conflicts'
-
elsif
@merge_request
.
work_in_progress?
=
render
'projects/merge_requests/widget/open/wip'
-
elsif
!
@
allowed_to_merge
-
elsif
!
@
merge_request
.
can_be_merged_by?
(
current_user
)
=
render
'projects/merge_requests/widget/open/not_allowed'
-
elsif
@merge_request
.
can_be_merged?
=
render
'projects/merge_requests/widget/open/accept'
...
...
app/views/projects/merge_requests/widget/open/_conflicts.html.haml
View file @
946b4ced
-
if
@
allowed_to_merge
-
if
@
merge_request
.
can_be_merged_by?
(
current_user
)
%h4
This merge request contains merge conflicts that must be resolved.
You can try it manually on the
...
...
app/views/projects/merge_requests/widget/open/_wip.html.haml
View file @
946b4ced
-
if
@
allowed_to_merge
-
if
@
merge_request
.
can_be_merged_by?
(
current_user
)
%h4
This merge request cannot be accepted because it is marked as Work In Progress.
...
...
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