diff options
Diffstat (limited to 'app/models/repository.rb')
| -rw-r--r-- | app/models/repository.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 97b4330092a..1255b814533 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -3,7 +3,7 @@ class Repository attr_accessor :raw_repository, :path_with_namespace - def initialize(path_with_namespace, default_branch) + def initialize(path_with_namespace, default_branch = nil) @path_with_namespace = path_with_namespace @raw_repository = Gitlab::Git::Repository.new(path_to_repo) if path_with_namespace rescue Gitlab::Git::Repository::NoRepository @@ -57,7 +57,7 @@ class Repository def recent_branches(limit = 20) branches.sort do |a, b| - a.commit.committed_date <=> b.commit.committed_date + b.commit.committed_date <=> a.commit.committed_date end[0..limit] end @@ -133,6 +133,7 @@ class Repository Rails.cache.delete(cache_key(:tag_names)) Rails.cache.delete(cache_key(:commit_count)) Rails.cache.delete(cache_key(:graph_log)) + Rails.cache.delete(cache_key(:readme)) end def graph_log @@ -159,4 +160,10 @@ class Repository def blob_at(sha, path) Gitlab::Git::Blob.find(self, sha, path) end + + def readme + Rails.cache.fetch(cache_key(:readme)) do + Tree.new(self, self.root_ref).readme + end + end end |
