summaryrefslogtreecommitdiffstats
path: root/vendor/code.gitea.io/git/tree.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-03 11:35:17 +0800
committertechknowlogick <matti@mdranta.net>2019-02-02 22:35:17 -0500
commitecefa9e724460deb70b97dd7c52fc8f4db94be93 (patch)
tree0d2ea72f0a682b7ab775879b5737782e4c000e69 /vendor/code.gitea.io/git/tree.go
parent3d91bb2f2dc8584b76a49a1a40c3f688c21380f5 (diff)
downloadgitea-ecefa9e724460deb70b97dd7c52fc8f4db94be93.tar.gz
gitea-ecefa9e724460deb70b97dd7c52fc8f4db94be93.zip
Add single commit API support (#5843)
* add single commit API support
Diffstat (limited to 'vendor/code.gitea.io/git/tree.go')
-rw-r--r--vendor/code.gitea.io/git/tree.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/vendor/code.gitea.io/git/tree.go b/vendor/code.gitea.io/git/tree.go
index b67bf55840..b65fe19409 100644
--- a/vendor/code.gitea.io/git/tree.go
+++ b/vendor/code.gitea.io/git/tree.go
@@ -18,6 +18,9 @@ type Tree struct {
entries Entries
entriesParsed bool
+
+ entriesRecursive Entries
+ entriesRecursiveParsed bool
}
// NewTree create a new tree according the repository and commit id
@@ -67,20 +70,29 @@ func (t *Tree) ListEntries() (Entries, error) {
if err != nil {
return nil, err
}
+
t.entries, err = parseTreeEntries(stdout, t)
+ if err == nil {
+ t.entriesParsed = true
+ }
+
return t.entries, err
}
// ListEntriesRecursive returns all entries of current tree recursively including all subtrees
func (t *Tree) ListEntriesRecursive() (Entries, error) {
- if t.entriesParsed {
- return t.entries, nil
+ if t.entriesRecursiveParsed {
+ return t.entriesRecursive, nil
}
stdout, err := NewCommand("ls-tree", "-t", "-r", t.ID.String()).RunInDirBytes(t.repo.Path)
-
if err != nil {
return nil, err
}
- t.entries, err = parseTreeEntries(stdout, t)
- return t.entries, err
+
+ t.entriesRecursive, err = parseTreeEntries(stdout, t)
+ if err == nil {
+ t.entriesRecursiveParsed = true
+ }
+
+ return t.entriesRecursive, err
}