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
5423e6e2
Commit
5423e6e2
authored
Jun 29, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-workhorse-format-patch' into 'master'
Workhorse to serve email diffs See merge request !4590
parents
d171ff17
db0a6c10
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
24 deletions
+25
-24
CHANGELOG
CHANGELOG
+1
-0
GITLAB_WORKHORSE_VERSION
GITLAB_WORKHORSE_VERSION
+1
-1
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 @
5423e6e2
...
...
@@ -6,6 +6,7 @@ v 8.10.0 (unreleased)
- Wrap code blocks on Activies and Todos page. !4783 (winniehell)
- Display last commit of deleted branch in push events !4699 (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
...
...
GITLAB_WORKHORSE_VERSION
View file @
5423e6e2
0.7.
5
0.7.
7
app/controllers/projects/merge_requests_controller.rb
View file @
5423e6e2
...
...
@@ -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 @
5423e6e2
...
...
@@ -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 @
5423e6e2
...
...
@@ -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 @
5423e6e2
...
...
@@ -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