Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit 7d7fe9f

Browse files
Kasi-Rlunny
authored andcommitted
Fixed a bug where TreeEntries were getting cached, (thanks @filipnavara) (#139)
1 parent c811eb4 commit 7d7fe9f

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tree.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ type Tree struct {
1818

1919
entries Entries
2020
entriesParsed bool
21+
22+
entriesRecursive Entries
23+
entriesRecursiveParsed bool
2124
}
2225

2326
// NewTree create a new tree according the repository and commit id
@@ -67,20 +70,29 @@ func (t *Tree) ListEntries() (Entries, error) {
6770
if err != nil {
6871
return nil, err
6972
}
73+
7074
t.entries, err = parseTreeEntries(stdout, t)
75+
if err == nil {
76+
t.entriesParsed = true
77+
}
78+
7179
return t.entries, err
7280
}
7381

7482
// ListEntriesRecursive returns all entries of current tree recursively including all subtrees
7583
func (t *Tree) ListEntriesRecursive() (Entries, error) {
76-
if t.entriesParsed {
77-
return t.entries, nil
84+
if t.entriesRecursiveParsed {
85+
return t.entriesRecursive, nil
7886
}
7987
stdout, err := NewCommand("ls-tree", "-t", "-r", t.ID.String()).RunInDirBytes(t.repo.Path)
80-
8188
if err != nil {
8289
return nil, err
8390
}
84-
t.entries, err = parseTreeEntries(stdout, t)
85-
return t.entries, err
91+
92+
t.entriesRecursive, err = parseTreeEntries(stdout, t)
93+
if err == nil {
94+
t.entriesRecursiveParsed = true
95+
}
96+
97+
return t.entriesRecursive, err
8698
}

0 commit comments

Comments
 (0)