Commit 00b44044 authored by http://jneen.net/'s avatar http://jneen.net/

skip the branch fetch if we already have the sha

parent c13f712c
......@@ -991,23 +991,27 @@ class Repository
end
def with_repo_branch_commit(start_repository, start_branch_name)
return yield(nil) if start_repository.empty_repo?
tmp_ref = nil
return yield nil if start_repository.empty_repo?
branch_name_or_sha =
branch_commit =
if start_repository == self
start_branch_name
commit(start_branch_name)
else
tmp_ref = fetch_ref(
start_repository.path_to_repo,
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{start_branch_name}",
"refs/tmp/#{SecureRandom.hex}/head"
)
start_repository.commit(start_branch_name).sha
sha = start_repository.find_branch(start_branch_name).target
commit(sha) ||
begin
tmp_ref = fetch_ref(
start_repository.path_to_repo,
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{start_branch_name}",
"refs/tmp/#{SecureRandom.hex}/head"
)
commit(start_repository.commit(start_branch_name).sha)
end
end
yield(commit(branch_name_or_sha))
yield branch_commit
ensure
rugged.references.delete(tmp_ref) if tmp_ref
end
......
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