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:
parent
07a982ff94
commit
5e74abd1b2
2 changed files with 8 additions and 1 deletions
4
main.go
4
main.go
|
@ -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"])
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue