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
01e1139f
Commit
01e1139f
authored
May 12, 2016
by
Zeger-Jan van de Weg
Committed by
Z.J. van de Weg
Jun 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workhorse to serve raw diffs
parent
ca3c5c29
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
30 deletions
+28
-30
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+10
-3
app/models/merge_request.rb
app/models/merge_request.rb
+0
-7
features/project/merge_requests.feature
features/project/merge_requests.feature
+0
-12
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+15
-2
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+3
-6
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
01e1139f
...
@@ -58,8 +58,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -58,8 +58,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
{
render
json:
@merge_request
}
format
.
json
{
render
json:
@merge_request
}
format
.
diff
{
render
text:
@merge_request
.
to_diff
}
format
.
patch
{
render
text:
@merge_request
.
to_patch
}
format
.
patch
{
render
text:
@merge_request
.
to_patch
}
format
.
diff
do
headers
.
store
(
*
Gitlab
::
Workhorse
.
send_git_diff
(
@project
.
repository
,
@merge_request
.
diff_base_commit
.
id
,
@merge_request
.
last_commit
.
id
))
headers
[
'Content-Disposition'
]
=
'inline'
head
:ok
end
end
end
end
end
...
...
app/models/merge_request.rb
View file @
01e1139f
...
@@ -313,13 +313,6 @@ class MergeRequest < ActiveRecord::Base
...
@@ -313,13 +313,6 @@ class MergeRequest < ActiveRecord::Base
)
)
end
end
# Returns the raw diff for this merge request
#
# see "git diff"
def
to_diff
target_project
.
repository
.
diff_text
(
diff_base_commit
.
sha
,
source_sha
)
end
# Returns the commit as a series of email patches.
# Returns the commit as a series of email patches.
#
#
# see "git format-patch"
# see "git format-patch"
...
...
features/project/merge_requests.feature
View file @
01e1139f
...
@@ -76,18 +76,6 @@ Feature: Project Merge Requests
...
@@ -76,18 +76,6 @@ Feature: Project Merge Requests
And
I submit new merge request
"Wiki Feature"
And
I submit new merge request
"Wiki Feature"
Then
I should see merge request
"Wiki Feature"
Then
I should see merge request
"Wiki Feature"
Scenario
:
I
download a diff on a public merge request
Given
public project
"Community"
And
"John Doe"
owns public project
"Community"
And
project
"Community"
has
"Bug CO-01"
open merge request with diffs inside
Given
I logout directly
And
I visit merge request page
"Bug CO-01"
And
I click on
"Email Patches"
Then
I should see a patch diff
And
I visit merge request page
"Bug CO-01"
And
I click on
"Plain Diff"
Then
I should see a patch diff
@javascript
@javascript
Scenario
:
I
comment on a merge request
Scenario
:
I
comment on a merge request
Given
I visit merge request page
"Bug NS-04"
Given
I visit merge request page
"Bug NS-04"
...
...
lib/gitlab/workhorse.rb
View file @
01e1139f
...
@@ -30,6 +30,19 @@ module Gitlab
...
@@ -30,6 +30,19 @@ module Gitlab
]
]
end
end
def
send_git_diff
(
repository
,
from
,
to
)
params
=
{
'RepoPath'
=>
repository
.
path_to_repo
,
'ShaFrom'
=>
from
,
'ShaTo'
=>
to
}
[
SEND_DATA_HEADER
,
"git-diff:
#{
encode
(
params
)
}
"
]
end
protected
protected
def
encode
(
hash
)
def
encode
(
hash
)
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
01e1139f
...
@@ -84,17 +84,14 @@ describe Projects::MergeRequestsController do
...
@@ -84,17 +84,14 @@ describe Projects::MergeRequestsController do
end
end
describe
"as diff"
do
describe
"as diff"
do
include_examples
"export merge as"
,
:diff
it
"triggers workhorse to serve the request"
do
let
(
:format
)
{
:diff
}
it
"should really only be a git diff"
do
get
(
:show
,
get
(
:show
,
namespace_id:
project
.
namespace
.
to_param
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
project_id:
project
.
to_param
,
id:
merge_request
.
iid
,
id:
merge_request
.
iid
,
format:
format
)
format:
:diff
)
expect
(
response
.
body
).
to
start_with
(
"diff --git
"
)
expect
(
response
.
headers
[
'Gitlab-Workhorse-Send-Data'
]).
to
start_with
(
"git-diff:
"
)
end
end
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