Commit d65db552 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

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
parent 26c9d716
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment