diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2018-04-26 15:11:31 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2018-04-26 15:11:31 -0500 |
commit | ab992b8aa7499dc685326d74888421578624af5c (patch) | |
tree | 0433fdc09bfee26edc03abfe7cc7253b32579758 | |
parent | 55f07cc32e7684b21e0c1662c70128df14c6abf7 (diff) | |
download | gitlab-ce-rd-backport-of-ee-5566.tar.gz |
Backport some changes from gitlab-ee!5476rd-backport-of-ee-5566
The lib/gitlab/git/repository.rb needs to have the same content between
gitlab-ce and gitlab-ee in order to have Gitaly working fine.
-rw-r--r-- | lib/gitlab/git/raw_diff_change.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 20 | ||||
-rw-r--r-- | spec/lib/gitlab/git/raw_diff_change_spec.rb | 2 |
3 files changed, 14 insertions, 9 deletions
diff --git a/lib/gitlab/git/raw_diff_change.rb b/lib/gitlab/git/raw_diff_change.rb index eb3d8819239..7f157fdf9f3 100644 --- a/lib/gitlab/git/raw_diff_change.rb +++ b/lib/gitlab/git/raw_diff_change.rb @@ -20,6 +20,7 @@ module Gitlab # 85bc2f9753afd5f4fc5d7c75f74f8d526f26b4f3 107 R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee def parse(raw_change) @blob_id, @blob_size, @raw_operation, raw_paths = raw_change.split(' ', 4) + @blob_size = @blob_size.to_i @operation = extract_operation @old_path, @new_path = extract_paths(raw_paths) end diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 5a6e2e0b937..e42cb581cba 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -565,19 +565,23 @@ module Gitlab # old_rev and new_rev are commit ID's # the result of this method is an array of Gitlab::Git::RawDiffChange def raw_changes_between(old_rev, new_rev) - result = [] + return [] if new_rev.nil? || new_rev == Gitlab::Git::BLANK_SHA - circuit_breaker.perform do - Open3.pipeline_r(git_diff_cmd(old_rev, new_rev), format_git_cat_file_script, git_cat_file_cmd) do |last_stdout, wait_threads| - last_stdout.each_line { |line| result << ::Gitlab::Git::RawDiffChange.new(line.chomp!) } + strong_memoize("changes_#{old_rev}_#{new_rev}".to_sym) do + result = [] + + circuit_breaker.perform do + Open3.pipeline_r(git_diff_cmd(old_rev, new_rev), format_git_cat_file_script, git_cat_file_cmd) do |last_stdout, wait_threads| + last_stdout.each_line { |line| result << ::Gitlab::Git::RawDiffChange.new(line.chomp!) } - if wait_threads.any? { |waiter| !waiter.value&.success? } - raise ::Gitlab::Git::Repository::GitError, "Unabled to obtain changes between #{old_rev} and #{new_rev}" + if wait_threads.any? { |waiter| !waiter.value&.success? } + raise ::Gitlab::Git::Repository::GitError, "Unable to obtain changes between #{old_rev} and #{new_rev}" + end end end - end - result + result + end end # Returns the SHA of the most recent common ancestor of +from+ and +to+ diff --git a/spec/lib/gitlab/git/raw_diff_change_spec.rb b/spec/lib/gitlab/git/raw_diff_change_spec.rb index eedde34534f..a0bb37fd84a 100644 --- a/spec/lib/gitlab/git/raw_diff_change_spec.rb +++ b/spec/lib/gitlab/git/raw_diff_change_spec.rb @@ -12,7 +12,7 @@ describe Gitlab::Git::RawDiffChange do expect(change.operation).to eq(:unknown) expect(change.old_path).to be_blank expect(change.new_path).to be_blank - expect(change.blob_size).to be_blank + expect(change.blob_size).to eq(0) end end |