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
ddec2ed0
Commit
ddec2ed0
authored
Jul 03, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add send_git_patch helper
parent
5ffb848e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
11 deletions
+21
-11
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+9
-6
app/helpers/workhorse_helper.rb
app/helpers/workhorse_helper.rb
+8
-1
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+3
-3
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+1
-1
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
ddec2ed0
...
...
@@ -58,14 +58,17 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
format
.
json
{
render
json:
@merge_request
}
format
.
json
do
render
json:
@merge_request
end
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
return
render_404
unless
@merge_request
.
diff_refs
send_git_patch
@project
.
repository
,
@merge_request
.
diff_refs
end
format
.
diff
do
return
render_404
unless
@merge_request
.
diff_refs
...
...
app/helpers/workhorse_helper.rb
View file @
ddec2ed0
# Helpers to send Git blobs, diffs or archives through Workhorse.
# Helpers to send Git blobs, diffs
, patches
or archives through Workhorse.
# Workhorse will also serve files when using `send_file`.
module
WorkhorseHelper
# Send a Git blob through Workhorse
...
...
@@ -16,6 +16,13 @@ module WorkhorseHelper
head
:ok
end
# Send a Git patch through Workhorse
def
send_git_patch
(
repository
,
diff_refs
)
headers
.
store
(
*
Gitlab
::
Workhorse
.
send_git_patch
(
repository
,
diff_refs
))
headers
[
'Content-Disposition'
]
=
'inline'
head
:ok
end
# Archive a Git repository and send it through Workhorse
def
send_git_archive
(
repository
,
ref
:,
format
:)
headers
.
store
(
*
Gitlab
::
Workhorse
.
send_git_archive
(
repository
,
ref:
ref
,
format:
format
))
...
...
lib/gitlab/workhorse.rb
View file @
ddec2ed0
...
...
@@ -50,11 +50,11 @@ module Gitlab
]
end
def
send_git_patch
(
repository
,
from
,
to
)
def
send_git_patch
(
repository
,
diff_refs
)
params
=
{
'RepoPath'
=>
repository
.
path_to_repo
,
'ShaFrom'
=>
from
,
'ShaTo'
=>
to
'ShaFrom'
=>
diff_refs
.
start_sha
,
'ShaTo'
=>
diff_refs
.
head_sha
}
[
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
ddec2ed0
...
...
@@ -103,7 +103,7 @@ describe Projects::MergeRequestsController do
id:
merge_request
.
iid
,
format: :patch
)
expect
(
response
.
headers
[
'Gitlab-Workhorse-Send-Data'
]).
to
start_with
(
"git-format-patch:"
)
expect
(
response
.
headers
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]).
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