-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
48 lines (36 loc) · 1000 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
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"fmt"
"os"
"github.com/utilitywarehouse/patrol/patrol"
)
func main() {
revision := flag.String("from", "", "revision that should be used to detected "+
"changes in HEAD.\nE.g.: -from=a0e002f951f56d53d552f9427b3331b11ea66e92")
allFiles := flag.Bool("all-files", false, "detect changes in all files, not just go files")
flag.Parse()
args := flag.Args()
if len(args) < 1 {
fmt.Fprintf(os.Stderr, "please provide the path to the repository\n")
os.Exit(1)
}
if *revision == "" {
fmt.Fprintf(os.Stderr, "please set `from` flag:\n\tpatrol -from=a0e002f951f56d53d552f9427b3331b11ea66e92 .\n")
os.Exit(1)
}
repoPath := args[0]
repo, err := patrol.NewRepo(repoPath)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err.Error())
os.Exit(1)
}
changes, err := repo.ChangesFrom(*revision, *allFiles)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err.Error())
os.Exit(1)
}
for _, c := range changes {
fmt.Println(c)
}
}