diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-16 10:42:06 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-16 10:44:38 +0100 |
commit | efd2792a8c966f021f54776373314f4e189f7a70 (patch) | |
tree | 743834d0c6d7bcd7f39fc4738ca4fc66dc659015 /examples/basic | |
parent | 56f5e4eda7a99c9db58227ea88e30cc9d7403e44 (diff) | |
download | go-git-efd2792a8c966f021f54776373314f4e189f7a70.tar.gz |
examples: basic
Diffstat (limited to 'examples/basic')
-rw-r--r-- | examples/basic/main.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/basic/main.go b/examples/basic/main.go new file mode 100644 index 0000000..c922d35 --- /dev/null +++ b/examples/basic/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "fmt" + "io" + "os" + + "gopkg.in/src-d/go-git.v2" +) + +func main() { + fmt.Printf("Retrieving %q ...\n", os.Args[2]) + r, err := git.NewRepository(os.Args[2], nil) + if err != nil { + panic(err) + } + + if err := r.Pull("origin", "refs/heads/master"); err != nil { + panic(err) + } + + dumpCommits(r) +} + +func dumpCommits(r *git.Repository) { + iter := r.Commits() + defer iter.Close() + + for { + commit, err := iter.Next() + if err != nil { + if err == io.EOF { + break + } + + panic(err) + } + + fmt.Println(commit) + } +} |