From ad937d270c3fb4337a091841dc41ee0135a8a840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 6 Nov 2017 16:29:13 +0100 Subject: [PATCH] Cache the root ref SHA in an instance variable in Repository#merged_to_root_ref? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- app/models/repository.rb | 6 +++--- 1 file 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