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
c31f876a
Commit
c31f876a
authored
Jun 10, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workhorse to serve email diffs
Depends on the changes in Workhorse (gitlab-org/gitlab-workhorse!48).
parent
e0e32562
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
23 deletions
+24
-23
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+7
-1
app/models/merge_request.rb
app/models/merge_request.rb
+0
-7
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+13
-0
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+3
-15
No files found.
CHANGELOG
View file @
c31f876a
...
...
@@ -4,6 +4,7 @@ v 8.10.0 (unreleased)
- Replace Haml with Hamlit to make view rendering faster. !3666
- Wrap code blocks on Activies and Todos page. !4783 (winniehell)
- Add Sidekiq queue duration to transaction metrics.
- Let Workhorse serve format-patch diffs
- Make images fit to the size of the viewport !4810
- Fix check for New Branch button on Issue page !4630 (winniehell)
- Fix MR-auto-close text added to description. !4836
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
c31f876a
...
...
@@ -59,7 +59,13 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
format
.
json
{
render
json:
@merge_request
}
format
.
patch
{
render
text:
@merge_request
.
to_patch
}
format
.
patch
do
headers
.
store
(
*
Gitlab
::
Workhorse
.
send_git_patch
(
@project
.
repository
,
@merge_request
.
diff_base_commit
.
id
,
@merge_request
.
last_commit
.
id
))
headers
[
'Content-Disposition'
]
=
'inline'
head
:ok
end
format
.
diff
do
return
render_404
unless
@merge_request
.
diff_refs
...
...
app/models/merge_request.rb
View file @
c31f876a
...
...
@@ -319,13 +319,6 @@ class MergeRequest < ActiveRecord::Base
)
end
# Returns the commit as a series of email patches.
#
# see "git format-patch"
def
to_patch
target_project
.
repository
.
format_patch
(
diff_base_commit
.
sha
,
source_sha
)
end
def
hook_attrs
attrs
=
{
source:
source_project
.
try
(
:hook_attrs
),
...
...
lib/gitlab/workhorse.rb
View file @
c31f876a
...
...
@@ -52,6 +52,19 @@ module Gitlab
]
end
def
send_git_patch
(
repository
,
from
,
to
)
params
=
{
'RepoPath'
=>
repository
.
path_to_repo
,
'ShaFrom'
=>
from
,
'ShaTo'
=>
to
}
[
SEND_DATA_HEADER
,
"git-format-patch:
#{
encode
(
params
)
}
"
]
end
protected
def
encode
(
hash
)
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
c31f876a
...
...
@@ -96,26 +96,14 @@ describe Projects::MergeRequestsController do
end
describe
"as patch"
do
include_examples
"export merge as"
,
:patch
let
(
:format
)
{
:patch
}
it
"should really be a git email patch with commit"
do
get
(
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
merge_request
.
iid
,
format:
format
)
expect
(
response
.
body
[
0
..
100
]).
to
start_with
(
"From
#{
merge_request
.
commits
.
last
.
id
}
"
)
end
it
"should contain git diffs"
do
it
'triggers workhorse to serve the request'
do
get
(
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
merge_request
.
iid
,
format:
format
)
format:
:patch
)
expect
(
response
.
body
).
to
match
(
/^diff --git/
)
expect
(
response
.
headers
[
'Gitlab-Workhorse-Send-Data'
]).
to
start_with
(
"git-format-patch:"
)
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