Merge branch 'zj-workhorse-to-serve-diffs' into 'master'
Workhorse to serve raw diffs Fixes (partially) #13999 Dependent on: gitlab-org/gitlab-workhorse!45 See merge request !4130
This commit is contained in:
commit
afa21054fa
7 changed files with 30 additions and 31 deletions
|
@ -172,6 +172,7 @@ v 8.7.6
|
|||
- Fix import from GitLab.com to a private instance failure. !4181
|
||||
- Fix external imports not finding the import data. !4106
|
||||
- Fix notification delay when changing status of an issue
|
||||
- Bump Workhorse to 0.7.5 so it can serve raw diffs
|
||||
|
||||
v 8.7.5
|
||||
- Fix relative links in wiki pages. !4050
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.7.4
|
||||
0.7.5
|
||||
|
|
|
@ -59,8 +59,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @merge_request }
|
||||
format.diff { render text: @merge_request.to_diff }
|
||||
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
|
||||
|
||||
|
|
|
@ -313,13 +313,6 @@ class MergeRequest < ActiveRecord::Base
|
|||
)
|
||||
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.
|
||||
#
|
||||
# see "git format-patch"
|
||||
|
|
|
@ -74,18 +74,6 @@ Feature: Project Merge Requests
|
|||
And I submit new 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
|
||||
Scenario: I comment on a merge request
|
||||
Given I visit merge request page "Bug NS-04"
|
||||
|
|
|
@ -30,6 +30,19 @@ module Gitlab
|
|||
]
|
||||
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
|
||||
|
||||
def encode(hash)
|
||||
|
|
|
@ -84,17 +84,14 @@ describe Projects::MergeRequestsController do
|
|||
end
|
||||
|
||||
describe "as diff" do
|
||||
include_examples "export merge as", :diff
|
||||
let(:format) { :diff }
|
||||
|
||||
it "should really only be a git diff" 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: :diff)
|
||||
|
||||
expect(response.body).to start_with("diff --git")
|
||||
expect(response.headers['Gitlab-Workhorse-Send-Data']).to start_with("git-diff:")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue