From 2ed3474ab8e52c98a87e390d5128d45d693a115d Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Mon, 22 Aug 2016 03:29:05 +0200 Subject: ForEach review and Commit.Tree err return --- examples/basic/main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'examples/basic/main.go') diff --git a/examples/basic/main.go b/examples/basic/main.go index e192cef..85d6a57 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -35,16 +35,15 @@ func main() { color.Blue("git ls-tree -r HEAD") // ... retrieve the tree from the commit - tree := commit.Tree() - // ... create a tree walker, allows to you intereste all nested trees - walker := git.NewTreeWalker(r, tree) - walker.ForEach(func(fullpath string, e git.TreeEntry) error { + tree, _ := commit.Tree() + // ... get the files iterator and print the file + tree.Files().ForEach(func(f *git.File) error { // we ignore the tree - if e.Mode.Perm() == 0 { + if f.Mode.Perm() == 0 { return nil } - fmt.Printf("100644 blob %s %s\n", e.Hash, fullpath) + fmt.Printf("100644 blob %s %s\n", f.Hash, f.Name) return nil }) } -- cgit