diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-04-25 09:01:28 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-04-25 09:01:28 +0200 |
commit | bcefb5bf829b841d9d12a27a06099b67c609b5f8 (patch) | |
tree | 273cad16130aa6cd05952e1aca88b9f41dc135c9 /examples/latest | |
parent | 74b8b53b28d444542edc77e0beec19bbab8e8037 (diff) | |
download | go-git-bcefb5bf829b841d9d12a27a06099b67c609b5f8.tar.gz |
documentation
Diffstat (limited to 'examples/latest')
-rw-r--r-- | examples/latest/latest.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/latest/latest.go b/examples/latest/latest.go new file mode 100644 index 0000000..84aaf48 --- /dev/null +++ b/examples/latest/latest.go @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "os" + + "gopkg.in/src-d/go-git.v3" +) + +func main() { + fmt.Printf("Retrieving latest commit from: %q ...\n", os.Args[1]) + r, err := git.NewRepository(os.Args[1], nil) + if err != nil { + panic(err) + } + + if err := r.Pull(git.DefaultRemoteName, "refs/heads/master"); err != nil { + panic(err) + } + + hash, err := r.Remotes[git.DefaultRemoteName].Head() + if err != nil { + panic(err) + } + + commit, err := r.Commit(hash) + if err != nil { + panic(err) + } + + fmt.Println(commit) +} |