diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-21 23:45:08 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-21 23:45:08 +0300 |
commit | d96098e966f70afcf6f3bfa1ed1bc20be2672fc8 (patch) | |
tree | 9451da684fd52941a3fac74bfe2fe31e018850ab /app | |
parent | c378d20c8440aff83a8bd54c5aed9f06a9c205f8 (diff) |
Cache head commit and head tree
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 7b8a34eba2c..082ad7a0c6a 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -248,12 +248,20 @@ class Repository end def head_commit - commit(self.root_ref) + @head_commit ||= commit(self.root_ref) + end + + def head_tree + @head_tree ||= Tree.new(self, head_commit.sha, nil) end def tree(sha = :head, path = nil) if sha == :head - sha = head_commit.sha + if path.nil? + return head_tree + else + sha = head_commit.sha + end end Tree.new(self, sha, path) |