Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-06-12 13:33:47 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-06-12 13:48:09 +0300
commitd65db552af743a139e53abb99fe1ec51b6a440e0 (patch)
treeac6a69a2fb37518b2b786e206efd7f0ee334e2d2
parent26c9d71666d0350b17431a75d8c31d0316bd7220 (diff)
Migrate compare_source_branch to use only Gitaly
Initially expected this to be a full blown migration, but that wasn't the case as we could fetch to a reference that would be deleted after the instanciation of the Diff object. This is a racy RPC, as #delete_refs is called and garbage collections runs right than, the commit can't be found later. Closes https://gitlab.com/gitlab-org/gitaly/issues/771
-rw-r--r--lib/gitlab/git/repository.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 63e1102f686..b1cf1b12910 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1181,18 +1181,18 @@ module Gitlab
end
def compare_source_branch(target_branch_name, source_repository, source_branch_name, straight:)
- Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- with_repo_branch_commit(source_repository, source_branch_name) do |commit|
- break unless commit
+ tmp_ref = "refs/tmp/#{SecureRandom.hex}"
- Gitlab::Git::Compare.new(
- self,
- target_branch_name,
- commit.sha,
- straight: straight
- )
- end
- end
+ return unless fetch_source_branch!(source_repository, source_branch_name, tmp_ref)
+
+ Gitlab::Git::Compare.new(
+ self,
+ target_branch_name,
+ tmp_ref,
+ straight: straight
+ )
+ ensure
+ delete_refs(tmp_ref)
end
def write_ref(ref_path, ref, old_ref: nil, shell: true)