Make all Gitaly diff flags mandatory

This commit is contained in:
Jacob Vosmaer 2018-07-06 12:01:15 +02:00
parent f5b12225d8
commit b012abee8b
4 changed files with 27 additions and 51 deletions

View File

@ -42,12 +42,10 @@ module Gitlab
return if @overflow return if @overflow
return if @iterator.nil? return if @iterator.nil?
Gitlab::GitalyClient.migrate(:commit_raw_diffs) do |is_enabled| if @iterator.is_a?(Gitlab::GitalyClient::DiffStitcher)
if is_enabled && @iterator.is_a?(Gitlab::GitalyClient::DiffStitcher) each_gitaly_patch(&block)
each_gitaly_patch(&block) else
else each_serialized_patch(&block)
each_rugged_patch(&block)
end
end end
@populated = true @populated = true
@ -118,7 +116,7 @@ module Gitlab
end end
end end
def each_rugged_patch def each_serialized_patch
i = @array.length i = @array.length
@iterator.each do |raw| @iterator.each do |raw|

View File

@ -555,13 +555,7 @@ module Gitlab
# diff options. The +options+ hash can also include :break_rewrites to # diff options. The +options+ hash can also include :break_rewrites to
# split larger rewrites into delete/add pairs. # split larger rewrites into delete/add pairs.
def diff(from, to, options = {}, *paths) def diff(from, to, options = {}, *paths)
iterator = gitaly_migrate(:diff_between) do |is_enabled| iterator = gitaly_commit_client.diff(from, to, options.merge(paths: paths))
if is_enabled
gitaly_commit_client.diff(from, to, options.merge(paths: paths))
else
diff_patches(from, to, options, *paths)
end
end
Gitlab::Git::DiffCollection.new(iterator, options) Gitlab::Git::DiffCollection.new(iterator, options)
end end

View File

@ -91,16 +91,12 @@ module Gitlab
end end
def send_git_diff(repository, diff_refs) def send_git_diff(repository, diff_refs)
params = if Gitlab::GitalyClient.feature_enabled?(:workhorse_send_git_diff, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) params = {
{ 'GitalyServer' => gitaly_server_hash(repository),
'GitalyServer' => gitaly_server_hash(repository), 'RawDiffRequest' => Gitaly::RawDiffRequest.new(
'RawDiffRequest' => Gitaly::RawDiffRequest.new( gitaly_diff_or_patch_hash(repository, diff_refs)
gitaly_diff_or_patch_hash(repository, diff_refs) ).to_json
).to_json }
}
else
workhorse_diff_or_patch_hash(repository, diff_refs)
end
[ [
SEND_DATA_HEADER, SEND_DATA_HEADER,

View File

@ -143,34 +143,22 @@ describe Gitlab::Workhorse do
let(:diff_refs) { double(base_sha: "base", head_sha: "head") } let(:diff_refs) { double(base_sha: "base", head_sha: "head") }
subject { described_class.send_git_diff(repository, diff_refs) } subject { described_class.send_git_diff(repository, diff_refs) }
context 'when Gitaly workhorse_send_git_diff feature is enabled' do it 'sets the header correctly' do
it 'sets the header correctly' do key, command, params = decode_workhorse_header(subject)
key, command, params = decode_workhorse_header(subject)
expect(key).to eq("Gitlab-Workhorse-Send-Data") expect(key).to eq("Gitlab-Workhorse-Send-Data")
expect(command).to eq("git-diff") expect(command).to eq("git-diff")
expect(params).to eq({ expect(params).to eq({
'GitalyServer' => { 'GitalyServer' => {
address: Gitlab::GitalyClient.address(project.repository_storage), address: Gitlab::GitalyClient.address(project.repository_storage),
token: Gitlab::GitalyClient.token(project.repository_storage) token: Gitlab::GitalyClient.token(project.repository_storage)
}, },
'RawDiffRequest' => Gitaly::RawDiffRequest.new( 'RawDiffRequest' => Gitaly::RawDiffRequest.new(
repository: repository.gitaly_repository, repository: repository.gitaly_repository,
left_commit_id: 'base', left_commit_id: 'base',
right_commit_id: 'head' right_commit_id: 'head'
).to_json ).to_json
}.deep_stringify_keys) }.deep_stringify_keys)
end
end
context 'when Gitaly workhorse_send_git_diff feature is disabled', :disable_gitaly do
it 'sets the header correctly' do
key, command, params = decode_workhorse_header(subject)
expect(key).to eq("Gitlab-Workhorse-Send-Data")
expect(command).to eq("git-diff")
expect(params).to eq("RepoPath" => repository.path_to_repo, "ShaFrom" => "base", "ShaTo" => "head")
end
end end
end end