-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 789 Bytes
/
main.go
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
29
30
31
32
33
34
35
36
37
package main
import (
"fmt"
"log"
"time"
"gopkg.in/src-d/go-git.v4"
)
func main() {
repo, err := git.PlainOpen(".")
if err != nil {
log.Fatalf("failed to open git repo: %v", err)
}
head, err := repo.Head()
if err != nil {
log.Fatalf("failed to get repo HEAD: %v", err)
}
iter, err := repo.Log(&git.LogOptions{From: head.Hash()})
if err != nil {
log.Fatalf("failed to get repo log: %v", err)
}
lastCommit, err := iter.Next()
if err != nil {
log.Fatalf("failed to get last commit: %v", err)
}
fmt.Println("# generated by benchcontext")
fmt.Printf("by: %s\n", lastCommit.Author.Email)
fmt.Printf("branch: %s\n", head.Name().Short())
fmt.Printf("commit: %s\n", lastCommit.Hash)
fmt.Printf("commit-time: %s\n", lastCommit.Author.When.Format(time.RFC3339))
}