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
path: root/app
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 /app
parentf43d94a6302a699c47749d9abe2287baf942e423 (diff)
Make Repository#has_visible_content more efficient
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index f0de2697dfc..1f4df50a913 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -91,12 +91,6 @@ class Repository
)
end
- # we need to have this method here because it is not cached in ::Git and
- # the method is called multiple times for every request
- def has_visible_content?
- branch_count > 0
- end
-
def inspect
"#<#{self.class.name}:#{@disk_path}>"
end
@@ -523,9 +517,10 @@ class Repository
delegate :tag_names, to: :raw_repository
cache_method :tag_names, fallback: []
- delegate :branch_count, :tag_count, to: :raw_repository
+ delegate :branch_count, :tag_count, :has_visible_content?, to: :raw_repository
cache_method :branch_count, fallback: 0
cache_method :tag_count, fallback: 0
+ cache_method :has_visible_content?, fallback: false
def avatar
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38327