diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-09 09:42:30 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-09 09:42:30 +0000 |
commit | 1a78483b49a744892743b9b13a118fe7353031e8 (patch) | |
tree | e86538005580397de1179fae5434cf555b2c9f29 | |
parent | c17e9a63606f552b75ee6b1aff8b96cd1d5116e0 (diff) | |
parent | b012abee8bc6fc183d3b5f4f6bc009726d52e285 (diff) | |
download | gitlab-ce-1a78483b49a744892743b9b13a118fe7353031e8.tar.gz |
Merge branch 'gitaly-diff-mandatory' into 'master'
Make all Gitaly diff flags mandatory
Closes gitaly#528 and gitaly#222
See merge request gitlab-org/gitlab-ce!20424
-rw-r--r-- | lib/gitlab/git/diff_collection.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/workhorse.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/workhorse_spec.rb | 42 |
4 files changed, 27 insertions, 51 deletions
diff --git a/lib/gitlab/git/diff_collection.rb b/lib/gitlab/git/diff_collection.rb index 6a601561c2a..219c69893ad 100644 --- a/lib/gitlab/git/diff_collection.rb +++ b/lib/gitlab/git/diff_collection.rb @@ -42,12 +42,10 @@ module Gitlab return if @overflow return if @iterator.nil? - Gitlab::GitalyClient.migrate(:commit_raw_diffs) do |is_enabled| - if is_enabled && @iterator.is_a?(Gitlab::GitalyClient::DiffStitcher) - each_gitaly_patch(&block) - else - each_rugged_patch(&block) - end + if @iterator.is_a?(Gitlab::GitalyClient::DiffStitcher) + each_gitaly_patch(&block) + else + each_serialized_patch(&block) end @populated = true @@ -118,7 +116,7 @@ module Gitlab end end - def each_rugged_patch + def each_serialized_patch i = @array.length @iterator.each do |raw| diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 29b3663a52a..6f0632addfa 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -555,13 +555,7 @@ module Gitlab # diff options. The +options+ hash can also include :break_rewrites to # split larger rewrites into delete/add pairs. def diff(from, to, options = {}, *paths) - iterator = gitaly_migrate(:diff_between) do |is_enabled| - if is_enabled - gitaly_commit_client.diff(from, to, options.merge(paths: paths)) - else - diff_patches(from, to, options, *paths) - end - end + iterator = gitaly_commit_client.diff(from, to, options.merge(paths: paths)) Gitlab::Git::DiffCollection.new(iterator, options) end diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index e893e46ee86..79483ee05f8 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -91,16 +91,12 @@ module Gitlab end def send_git_diff(repository, diff_refs) - params = if Gitlab::GitalyClient.feature_enabled?(:workhorse_send_git_diff, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) - { - 'GitalyServer' => gitaly_server_hash(repository), - 'RawDiffRequest' => Gitaly::RawDiffRequest.new( - gitaly_diff_or_patch_hash(repository, diff_refs) - ).to_json - } - else - workhorse_diff_or_patch_hash(repository, diff_refs) - end + params = { + 'GitalyServer' => gitaly_server_hash(repository), + 'RawDiffRequest' => Gitaly::RawDiffRequest.new( + gitaly_diff_or_patch_hash(repository, diff_refs) + ).to_json + } [ SEND_DATA_HEADER, diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index 660671cefaf..570580e0cfc 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -143,34 +143,22 @@ describe Gitlab::Workhorse do let(:diff_refs) { double(base_sha: "base", head_sha: "head") } 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 - 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({ - 'GitalyServer' => { - address: Gitlab::GitalyClient.address(project.repository_storage), - token: Gitlab::GitalyClient.token(project.repository_storage) - }, - 'RawDiffRequest' => Gitaly::RawDiffRequest.new( - repository: repository.gitaly_repository, - left_commit_id: 'base', - right_commit_id: 'head' - ).to_json - }.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) + 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 + expect(key).to eq("Gitlab-Workhorse-Send-Data") + expect(command).to eq("git-diff") + expect(params).to eq({ + 'GitalyServer' => { + address: Gitlab::GitalyClient.address(project.repository_storage), + token: Gitlab::GitalyClient.token(project.repository_storage) + }, + 'RawDiffRequest' => Gitaly::RawDiffRequest.new( + repository: repository.gitaly_repository, + left_commit_id: 'base', + right_commit_id: 'head' + ).to_json + }.deep_stringify_keys) end end |