summaryrefslogtreecommitdiff
path: root/app/models/repository.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 2a12b36a84d..c0c5816d151 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -312,11 +312,13 @@ class Repository
if !branch_name || branch_name == root_ref
branches.each do |branch|
cache.expire(:"diverging_commit_counts_#{branch.name}")
+ cache.expire(:"commit_count_#{branch.name}")
end
# In case a commit is pushed to a non-root branch we only have to flush the
# cache for said branch.
else
cache.expire(:"diverging_commit_counts_#{branch_name}")
+ cache.expire(:"commit_count_#{branch_name}")
end
end
@@ -496,6 +498,14 @@ class Repository
end
cache_method :commit_count, fallback: 0
+ def commit_count_for_ref(ref)
+ return 0 if empty?
+
+ cache.fetch(:"commit_count_#{ref}") do
+ raw_repository.commit_count(ref)
+ end
+ end
+
def branch_names
branches.map(&:name)
end