aboutsummaryrefslogtreecommitdiffstats
path: root/examples/latest
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-14 00:44:18 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-14 00:44:18 +0200
commitf826cf9d42cc34e2ae5aaf6ede892ecab9d2f198 (patch)
tree7555e7596887f239ce26828e98142e4df25c388f /examples/latest
parent79087748f60f9aba219624a0fe9f4d33a0b51236 (diff)
downloadgo-git-f826cf9d42cc34e2ae5aaf6ede892ecab9d2f198.tar.gz
fix tests and examples
Diffstat (limited to 'examples/latest')
-rw-r--r--examples/latest/latest.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/examples/latest/latest.go b/examples/latest/latest.go
index 2ccddf1..684ebb7 100644
--- a/examples/latest/latest.go
+++ b/examples/latest/latest.go
@@ -8,17 +8,23 @@ import (
)
func main() {
- fmt.Printf("Retrieving latest commit from: %q ...\n", os.Args[1])
- r, err := git.NewRepository(os.Args[1], nil)
+ url := os.Args[1]
+
+ fmt.Printf("Retrieving latest commit from: %q ...\n", url)
+ r, err := git.NewMemoryRepository()
if err != nil {
panic(err)
}
- if err = r.Pull(git.DefaultRemoteName, "refs/heads/master"); err != nil {
+ if err = r.Clone(&git.CloneOptions{URL: url}); err != nil {
+ panic(err)
+ }
+
+ head, err := r.Head()
+ if err != nil {
panic(err)
}
- head := r.Remotes[git.DefaultRemoteName].Head()
commit, err := r.Commit(head.Hash())
if err != nil {
panic(err)