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
|
||||
}
|
||||
|
||||
// reduce the set being run
|
||||
rules := validate.RegisteredRules
|
||||
if *flRun != "" {
|
||||
rules = validate.FilterRules(rules, validate.SanitizeFilters(*flRun))
|
||||
}
|
||||
|
||||
// Guess the commits we're working with
|
||||
var commitrange string
|
||||
if *flCommitRange != "" {
|
||||
commitrange = *flCommitRange
|
||||
|
@ -51,11 +53,13 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
// collect the entries
|
||||
c, err := git.Commits(commitrange)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// run them and show results
|
||||
results := validate.Results{}
|
||||
for _, commit := range c {
|
||||
fmt.Printf(" * %s %s ... ", commit["abbreviated_commit"], commit["subject"])
|
||||
|
|
|
@ -13,14 +13,17 @@ func init() {
|
|||
}
|
||||
|
||||
var (
|
||||
// ValidDCO is the regexp for signed off DCO
|
||||
ValidDCO = regexp.MustCompile(`^Signed-off-by: ([^<]+) <([^<>@]+@[^<>]+)>$`)
|
||||
DcoRule = validate.Rule{
|
||||
// DcoRule is the rule being registered
|
||||
DcoRule = validate.Rule{
|
||||
Name: "DCO",
|
||||
Description: "makes sure the commits are signed",
|
||||
Run: ValidateDCO,
|
||||
}
|
||||
)
|
||||
|
||||
// ValidateDCO is the ValidateRule for a git commit
|
||||
func ValidateDCO(c git.CommitEntry) (vr validate.Result) {
|
||||
vr.CommitEntry = c
|
||||
if len(strings.Split(c["parent"], " ")) > 1 {
|
||||
|
|
Loading…
Reference in a new issue