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 /lib/gitlab/git/repository.rb | |
parent | 55f07cc32e7684b21e0c1662c70128df14c6abf7 (diff) | |
download | gitlab-ce-ab992b8aa7499dc685326d74888421578624af5c.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.
Diffstat (limited to 'lib/gitlab/git/repository.rb')
-rw-r--r-- | lib/gitlab/git/repository.rb | 20 |
1 files changed, 12 insertions, 8 deletions
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+ |