-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpost_commit.go
More file actions
43 lines (33 loc) · 800 Bytes
/
post_commit.go
File metadata and controls
43 lines (33 loc) · 800 Bytes
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
38
39
40
41
42
43
package main
import (
"log"
"github.com/spf13/cobra"
)
func postCommitHookCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "hook-post-commit",
Short: "Processes a git post-commit hook event.",
Run: runPostCommit,
Hidden: true,
}
return cmd
}
func runPostCommit(cmd *cobra.Command, args []string) {
repo := getRepoOrExit()
head, err := repo.Head()
if err != nil {
log.Fatalf("Could not get repo HEAD")
}
commit, err := repo.LookupCommit(head.Target())
if err != nil {
log.Fatalf("Could not find commit pointed at by HEAD")
}
ident, err := GetRepoIdent(repo)
if err != nil {
log.Fatalln("Failed to retrieve identifier for repository")
}
m := newMessage()
m.Add(commitToSemanticForm(commit, ident))
recordHead(m, repo)
sendMapToPipeviz(m, repo)
}