Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-09-29 16:08:44 +0300
committerRémy Coutable <remy@rymai.me>2017-09-29 16:08:44 +0300
commit403712f06e776d7c2d97dd094fe55871a3137b8a (patch)
treefc25e813807b57248deea7a348881569aaaaad88 /lib/gitlab/git
parentf43d94a6302a699c47749d9abe2287baf942e423 (diff)
Make Repository#has_visible_content more efficient
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r--lib/gitlab/git/repository.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 6d710ffe2bb..449fb9d9c63 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -192,6 +192,28 @@ module Gitlab
end
end
+ def has_local_branches?
+ gitaly_migrate(:has_local_branches) do |is_enabled|
+ if is_enabled
+ gitaly_ref_client.has_local_branches?
+ else
+ has_local_branches_rugged?
+ end
+ end
+ end
+
+ def has_local_branches_rugged?
+ rugged.branches.each(:local).any? do |ref|
+ begin
+ ref.name && ref.target # ensures the branch is valid
+
+ true
+ rescue Rugged::ReferenceError
+ false
+ end
+ end
+ end
+
# Returns the number of valid tags
def tag_count
gitaly_migrate(:tag_names) do |is_enabled|
@@ -1037,7 +1059,9 @@ module Gitlab
# This method return true if repository contains some content visible in project page.
#
def has_visible_content?
- branch_count > 0
+ return @has_visible_content if defined?(@has_visible_content)
+
+ @has_visible_content = has_local_branches?
end
def gitaly_repository