blob: 2ccddf103087fb8ff04e6d70c3ece41dbe360895 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package main
import (
"fmt"
"os"
"gopkg.in/src-d/go-git.v4"
)
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)
}
head := r.Remotes[git.DefaultRemoteName].Head()
commit, err := r.Commit(head.Hash())
if err != nil {
panic(err)
}
fmt.Println(commit)
}
|