summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-11-06 16:29:13 +0100
committerRémy Coutable <remy@rymai.me>2017-11-06 16:29:13 +0100
commitad937d270c3fb4337a091841dc41ee0135a8a840 (patch)
tree7ec7fe9e6e4c8a266110b37eb1788ca5f3003411
parentb20984dea2fbbb20bc2807903115076b2a1de461 (diff)
downloadgitlab-ce-ad937d270c3fb4337a091841dc41ee0135a8a840.tar.gz
Cache the root ref SHA in an instance variable in Repository#merged_to_root_ref?
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--app/models/repository.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 69cddb36b2e..d445ef96322 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -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