forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
commitchecker.go
55 lines (48 loc) · 1.41 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
46
47
48
49
50
51
52
53
54
55
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 {
if err == util.ErrNotCommit {
fmt.Fprintf(os.Stderr, "WARNING: one of the provided commits does not exist, not a true branch\n")
os.Exit(0)
}
fmt.Fprintf(os.Stderr, "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.
// TODO: ...along with subtree merges.
nonbumpCommits := []util.Commit{}
for _, commit := range commits {
if !strings.HasPrefix(commit.Summary, "bump") {
nonbumpCommits = append(nonbumpCommits, commit)
}
}
errs := []string{}
for _, validate := range AllValidators {
if err := validate(nonbumpCommits); err != nil {
errs = append(errs, err.Error())
}
}
if len(os.Getenv("RESTORE_AND_VERIFY_GODEPS")) > 0 {
// Godeps verifies all commits, including bumps and UPSTREAM
if err := ValidateGodeps(commits); err != nil {
errs = append(errs, err.Error())
}
}
if len(errs) > 0 {
fmt.Fprintf(os.Stderr, "%s\n", strings.Join(errs, "\n\n"))
os.Exit(2)
}
}