aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-22 03:29:05 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-22 03:29:05 +0200
commit2ed3474ab8e52c98a87e390d5128d45d693a115d (patch)
tree6f136c2508c22f6b5146ef08c49821a45a5f2357 /examples
parent5b13c1a2e55cb442484d9c7b45389f422b110eec (diff)
downloadgo-git-2ed3474ab8e52c98a87e390d5128d45d693a115d.tar.gz
ForEach review and Commit.Tree err return
Diffstat (limited to 'examples')
-rw-r--r--examples/basic/main.go11
1 files changed, 5 insertions, 6 deletions
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
})
}