aboutsummaryrefslogblamecommitdiffstats
path: root/examples/basic/main.go
blob: 652ebf1b9dace99c35efda286d2da7c0493fb493 (plain) (tree)
1
2
3
4
5
6
7
8






             
                                  


             

                                                     



                          
                                              


                          



                                


                          
                                                                  











                                          
package main

import (
	"fmt"
	"io"
	"os"

	"gopkg.in/src-d/go-git.v3"
)

func main() {
	fmt.Printf("Retrieving %q ...\n", os.Args[1])
	r, err := git.NewRepository(os.Args[1], nil)
	if err != nil {
		panic(err)
	}

	if err = r.PullDefault(); err != nil {
		panic(err)
	}

	iter, err := r.Commits()
	if err != nil {
		panic(err)
	}
	defer iter.Close()

	for {
		//the commits are not shorted in any special order
		commit, err := iter.Next()
		if err != nil {
			if err == io.EOF {
				break
			}

			panic(err)
		}

		fmt.Println(commit)
	}
}