aboutsummaryrefslogtreecommitdiffstats
path: root/objects_test.go
diff options
context:
space:
mode:
authorJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-16 12:29:06 -0800
committerJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-17 04:46:57 -0800
commit9df17e545a445f58c5c43a1ece49bf1ff09e3b02 (patch)
treef1e50178d47e6c4bd68df613a338036280c30c9b /objects_test.go
parent6b0a5984ac0c69742e60a39ad9437fd981dbe31b (diff)
downloadgo-git-9df17e545a445f58c5c43a1ece49bf1ff09e3b02.tar.gz
New iteration behavior via FileIter and TreeWalker
Instead of returning a channel of files, Tree.Files() now returns a FileIter with these qualities: * It returns files in the original order of the repository (relying on a * new Tree.OrderedNames property) * It can return errors encountered when retrieving files and trees from * underlying storage * It can be Closed without having to drain the entire channel * It defers the heavy lifting to a new TreeWalker type * Its behavior is a little more consistent with other Iter types * It's a little less prone to memory leaks This update includes a new TreeWalker type that will iterate through all of the entries of a tree and its descendant subtrees. It does the dirty work that Tree.walkEntries() used to do, but with a public API. A new TreeIter type is also included that just walks through subtrees. This could be useful for performing a directory search while ignoring files/blobs altogether.
Diffstat (limited to 'objects_test.go')
-rw-r--r--objects_test.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/objects_test.go b/objects_test.go
index e8c5d6e..eadf65a 100644
--- a/objects_test.go
+++ b/objects_test.go
@@ -6,7 +6,7 @@ import (
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v3/core"
- "gopkg.in/src-d/go-git.v3/storages/memory"
+ "gopkg.in/src-d/go-git.v3/storage/memory"
)
type ObjectsSuite struct {
@@ -59,8 +59,9 @@ func (s *ObjectsSuite) TestParseTree(c *C) {
c.Assert(tree.Entries[".gitignore"].Hash.String(), Equals, "32858aad3c383ed1ff0a0f9bdf231d54a00c9e88")
count := 0
- ch := tree.Files()
- for f := range ch {
+ iter := tree.Files()
+ defer iter.Close()
+ for f, err := iter.Next(); err == nil; f, err = iter.Next() {
count++
if f.Name == "go/example.go" {
content, _ := ioutil.ReadAll(f)