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
2b1afa0e
Commit
2b1afa0e
authored
Nov 22, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove merge_request#raw and replace it with formats to #show
Needed to add a constraint on the id. Otherwise the format was parsed as part of the id.
parent
ddb7399a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
18 deletions
+17
-18
merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+5
-7
_diffs.html.haml
app/views/merge_requests/show/_diffs.html.haml
+4
-2
_mr_title.html.haml
app/views/merge_requests/show/_mr_title.html.haml
+2
-2
routes.rb
config/routes.rb
+1
-2
project_routing_spec.rb
spec/routing/project_routing_spec.rb
+5
-5
No files found.
app/controllers/merge_requests_controller.rb
View file @
2b1afa0e
class
MergeRequestsController
<
ProjectResourceController
before_filter
:module_enabled
before_filter
:merge_request
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
,
:automerge
,
:automerge_check
,
:raw
]
before_filter
:validates_merge_request
,
only:
[
:show
,
:diffs
,
:raw
]
before_filter
:merge_request
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
,
:automerge
,
:automerge_check
]
before_filter
:validates_merge_request
,
only:
[
:show
,
:diffs
]
before_filter
:define_show_vars
,
only:
[
:show
,
:diffs
]
# Allow read any merge_request
...
...
@@ -16,7 +16,6 @@ class MergeRequestsController < ProjectResourceController
# Allow destroy merge_request
before_filter
:authorize_admin_merge_request!
,
only:
[
:destroy
]
def
index
@merge_requests
=
MergeRequestsLoadContext
.
new
(
project
,
current_user
,
params
).
execute
end
...
...
@@ -25,11 +24,10 @@ class MergeRequestsController < ProjectResourceController
respond_to
do
|
format
|
format
.
html
format
.
js
end
end
def
raw
send_file
@merge_request
.
to_raw
format
.
diff
{
render
text:
@merge_request
.
to_diff
}
format
.
patch
{
render
text:
@merge_request
.
to_patch
}
end
end
def
diffs
...
...
app/views/merge_requests/show/_diffs.html.haml
View file @
2b1afa0e
-
if
@merge_request
.
valid_diffs?
=
render
"commits/diffs"
,
diffs:
@diffs
-
elsif
@merge_request
.
broken_diffs?
%h4
.nothing_here_message
%h4
.nothing_here_message
Can't load diff.
You can
#{
link_to
"download MR patch"
,
raw_project_merge_request_path
(
@project
,
@merge_request
),
class:
"vlink"
}
instead.
You can
=
link_to
"download it"
,
project_merge_request_path
(
@project
,
@merge_request
),
format: :diff
,
class:
"vlink"
instead.
-
else
%h4
.nothing_here_message
Nothing to merge
app/views/merge_requests/show/_mr_title.html.haml
View file @
2b1afa0e
...
...
@@ -13,9 +13,9 @@
=
"MERGED"
-
if
can?
(
current_user
,
:modify_merge_request
,
@merge_request
)
-
if
@merge_request
.
open?
=
link_to
raw_project_merge_request_path
(
@project
,
@merge_request
),
class:
"btn grouped"
do
=
link_to
project_merge_request_path
(
@project
,
@merge_request
,
format: :patch
),
class:
"btn grouped"
do
%i
.icon-download-alt
Get Patch
Get Patch
=
link_to
'Close'
,
project_merge_request_path
(
@project
,
@merge_request
,
merge_request:
{
closed:
true
},
status_only:
true
),
method: :put
,
class:
"btn grouped danger"
,
title:
"Close merge request"
...
...
config/routes.rb
View file @
2b1afa0e
...
...
@@ -159,12 +159,11 @@ Gitlab::Application.routes.draw do
end
end
resources
:merge_requests
do
resources
:merge_requests
,
constraints:
{
id:
/\d+/
}
do
member
do
get
:diffs
get
:automerge
get
:automerge_check
get
:raw
end
collection
do
...
...
spec/routing/project_routing_spec.rb
View file @
2b1afa0e
...
...
@@ -208,7 +208,6 @@ end
# diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) merge_requests#diffs
# automerge_project_merge_request GET /:project_id/merge_requests/:id/automerge(.:format) merge_requests#automerge
# automerge_check_project_merge_request GET /:project_id/merge_requests/:id/automerge_check(.:format) merge_requests#automerge_check
# raw_project_merge_request GET /:project_id/merge_requests/:id/raw(.:format) merge_requests#raw
# branch_from_project_merge_requests GET /:project_id/merge_requests/branch_from(.:format) merge_requests#branch_from
# branch_to_project_merge_requests GET /:project_id/merge_requests/branch_to(.:format) merge_requests#branch_to
# project_merge_requests GET /:project_id/merge_requests(.:format) merge_requests#index
...
...
@@ -231,10 +230,6 @@ describe MergeRequestsController, "routing" do
get
(
"/gitlabhq/merge_requests/1/automerge_check"
).
should
route_to
(
'merge_requests#automerge_check'
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
it
"to #raw"
do
get
(
"/gitlabhq/merge_requests/1/raw"
).
should
route_to
(
'merge_requests#raw'
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
it
"to #branch_from"
do
get
(
"/gitlabhq/merge_requests/branch_from"
).
should
route_to
(
'merge_requests#branch_from'
,
project_id:
'gitlabhq'
)
end
...
...
@@ -243,6 +238,11 @@ describe MergeRequestsController, "routing" do
get
(
"/gitlabhq/merge_requests/branch_to"
).
should
route_to
(
'merge_requests#branch_to'
,
project_id:
'gitlabhq'
)
end
it
"to #show"
do
get
(
"/gitlabhq/merge_requests/1.diff"
).
should
route_to
(
'merge_requests#show'
,
project_id:
'gitlabhq'
,
id:
'1'
,
format:
'diff'
)
get
(
"/gitlabhq/merge_requests/1.patch"
).
should
route_to
(
'merge_requests#show'
,
project_id:
'gitlabhq'
,
id:
'1'
,
format:
'patch'
)
end
it_behaves_like
"RESTful project resources"
do
let
(
:controller
)
{
'merge_requests'
}
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