forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitchecker.go
45 lines (38 loc) · 1.03 KB
/
commitchecker.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
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/openshift/origin/tools/rebasehelpers/util"
)
func main() {
var start, end string
flag.StringVar(&start, "start", "master", "The start of the revision range for analysis")
flag.StringVar(&end, "end", "HEAD", "The end of the revision range for analysis")
flag.Parse()
commits, err := util.CommitsBetween(start, end)
if err != nil {
os.Stderr.WriteString(fmt.Sprintf("ERROR: couldn't find commits from %s..%s: %v\n", start, end, err))
os.Exit(1)
}
// TODO: Filter out bump commits for now until we decide how to deal with
// them correctly.
nonbumpCommits := []util.Commit{}
for _, commit := range commits {
if !strings.HasPrefix(commit.Summary, "bump(") {
nonbumpCommits = append(nonbumpCommits, commit)
}
}
errs := []string{}
for _, validate := range AllValidators {
err := validate(nonbumpCommits)
if err != nil {
errs = append(errs, err.Error())
}
}
if len(errs) > 0 {
os.Stderr.WriteString(strings.Join(errs, "\n\n"))
os.Exit(2)
}
}