Cache head commit and head tree
This commit is contained in:
parent
c378d20c84
commit
d96098e966
|
@ -248,12 +248,20 @@ class Repository
|
||||||
end
|
end
|
||||||
|
|
||||||
def head_commit
|
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
|
end
|
||||||
|
|
||||||
def tree(sha = :head, path = nil)
|
def tree(sha = :head, path = nil)
|
||||||
if sha == :head
|
if sha == :head
|
||||||
sha = head_commit.sha
|
if path.nil?
|
||||||
|
return head_tree
|
||||||
|
else
|
||||||
|
sha = head_commit.sha
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Tree.new(self, sha, path)
|
Tree.new(self, sha, path)
|
||||||
|
|
Loading…
Reference in New Issue