aboutsummaryrefslogtreecommitdiffstats
path: root/examples/latest/latest.go
diff options
context:
space:
mode:
Diffstat (limited to 'examples/latest/latest.go')
-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)