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