aboutsummaryrefslogtreecommitdiffstats
path: root/tree_walker.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-22 00:18:02 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-22 00:18:02 +0200
commitf42d82364c5d159f65a48e720433ad2bc97f0b7f (patch)
tree82623f4163625786f4e8e41028dcd1c7abaf209f /tree_walker.go
parenta045606fc9c5cbf30b409384cbdad4804f01c61d (diff)
downloadgo-git-f42d82364c5d159f65a48e720433ad2bc97f0b7f.tar.gz
Remote.Fetch multiple RefSpec support
Diffstat (limited to 'tree_walker.go')
-rw-r--r--tree_walker.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/tree_walker.go b/tree_walker.go
index 5568e1b..1692c2f 100644
--- a/tree_walker.go
+++ b/tree_walker.go
@@ -3,6 +3,8 @@ package git
import (
"io"
"path"
+
+ "gopkg.in/src-d/go-git.v4/core"
)
const (
@@ -91,6 +93,27 @@ func (w *TreeWalker) Next() (name string, entry TreeEntry, obj Object, err error
return
}
+func (w *TreeWalker) ForEach(cb func(fullpath string, e TreeEntry) error) error {
+ for {
+ path, e, _, err := w.Next()
+ if err != nil {
+ if err == io.EOF {
+ return nil
+ }
+
+ return err
+ }
+
+ if err := cb(path, e); err != nil {
+ if err == core.ErrStop {
+ return nil
+ }
+
+ return err
+ }
+ }
+}
+
// Tree returns the tree that the tree walker most recently operated on.
func (w *TreeWalker) Tree() *Tree {
current := len(w.stack) - 1