1
0
Fork 0
mirror of https://github.com/vbatts/git-validation.git synced 2024-12-28 08:16:31 +00:00

*: comments and golint

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2015-10-05 18:55:05 -04:00
parent 07a982ff94
commit 5e74abd1b2
2 changed files with 8 additions and 1 deletions

View file

@ -32,11 +32,13 @@ func main() {
return return
} }
// reduce the set being run
rules := validate.RegisteredRules rules := validate.RegisteredRules
if *flRun != "" { if *flRun != "" {
rules = validate.FilterRules(rules, validate.SanitizeFilters(*flRun)) rules = validate.FilterRules(rules, validate.SanitizeFilters(*flRun))
} }
// Guess the commits we're working with
var commitrange string var commitrange string
if *flCommitRange != "" { if *flCommitRange != "" {
commitrange = *flCommitRange commitrange = *flCommitRange
@ -51,11 +53,13 @@ func main() {
} }
} }
// collect the entries
c, err := git.Commits(commitrange) c, err := git.Commits(commitrange)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
// run them and show results
results := validate.Results{} results := validate.Results{}
for _, commit := range c { for _, commit := range c {
fmt.Printf(" * %s %s ... ", commit["abbreviated_commit"], commit["subject"]) fmt.Printf(" * %s %s ... ", commit["abbreviated_commit"], commit["subject"])

View file

@ -13,14 +13,17 @@ func init() {
} }
var ( var (
// ValidDCO is the regexp for signed off DCO
ValidDCO = regexp.MustCompile(`^Signed-off-by: ([^<]+) <([^<>@]+@[^<>]+)>$`) ValidDCO = regexp.MustCompile(`^Signed-off-by: ([^<]+) <([^<>@]+@[^<>]+)>$`)
DcoRule = validate.Rule{ // DcoRule is the rule being registered
DcoRule = validate.Rule{
Name: "DCO", Name: "DCO",
Description: "makes sure the commits are signed", Description: "makes sure the commits are signed",
Run: ValidateDCO, Run: ValidateDCO,
} }
) )
// ValidateDCO is the ValidateRule for a git commit
func ValidateDCO(c git.CommitEntry) (vr validate.Result) { func ValidateDCO(c git.CommitEntry) (vr validate.Result) {
vr.CommitEntry = c vr.CommitEntry = c
if len(strings.Split(c["parent"], " ")) > 1 { if len(strings.Split(c["parent"], " ")) > 1 {