summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-11-07 11:09:00 +0000
committerDouwe Maan <douwe@gitlab.com>2017-11-07 11:09:00 +0000
commit8138d58d42cb128995b1f9d9ceab7f773c3300e3 (patch)
tree33d5d53a97755812ade5cdf93651edf4e6f6fa61 /app
parent31e3ef93e53802bb99b342a7b403972493ed63cc (diff)
parente78c701aff3fe57847552ca6db6a9ad615b555fb (diff)
downloadgitlab-ce-8138d58d42cb128995b1f9d9ceab7f773c3300e3.tar.gz
Merge branch '37442-api-branches-id-repository-branches-is-calling-gitaly-n-1-times-per-request' into 'master'
Fetch the merged branches at once in the `/projects/:id/repository/branches` endpoint See merge request gitlab-org/gitlab-ce!15215
Diffstat (limited to 'app')
-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 ef715d982ae..eb7766d040c 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