Cache the root ref SHA in an instance variable in Repository#merged_to_root_ref?

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2017-11-06 16:29:13 +01:00
parent b20984dea2
commit ad937d270c
No known key found for this signature in database
GPG Key ID: 46DF07E5CD9E96AB
1 changed files with 3 additions and 3 deletions

View File

@ -906,13 +906,13 @@ class Repository
branch = Gitlab::Git::Branch.find(self, branch_or_name)
if branch
root_ref_sha = commit(root_ref).sha
same_head = branch.target == root_ref_sha
@root_ref_sha ||= commit(root_ref).sha
same_head = branch.target == @root_ref_sha
merged =
if pre_loaded_merged_branches
pre_loaded_merged_branches.include?(branch.name)
else
ancestor?(branch.target, root_ref_sha)
ancestor?(branch.target, @root_ref_sha)
end
!same_head && merged