1
0
Fork 0
mirror of https://github.com/vbatts/git-validation.git synced 2025-05-29 16:22:26 +00:00

*: run tests in a runner

for cleanliness and ease of testing

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2015-10-06 10:44:04 -04:00
parent b9413c60c8
commit d614ccf997
4 changed files with 119 additions and 52 deletions

View file

@ -6,7 +6,7 @@ import (
)
var (
// DcoRule is the rule being registered
// ShortSubjectRule is the rule being registered
ShortSubjectRule = validate.Rule{
Name: "short-subject",
Description: "commit subjects are strictly less than 90 (github ellipsis length)",
@ -18,6 +18,8 @@ func init() {
validate.RegisterRule(ShortSubjectRule)
}
// ValidateShortSubject checks that the commit's subject is strictly less than
// 90 characters (preferrably not more than 72 chars).
func ValidateShortSubject(c git.CommitEntry) (vr validate.Result) {
if len(c["subject"]) >= 90 {
vr.Pass = false
@ -25,6 +27,10 @@ func ValidateShortSubject(c git.CommitEntry) (vr validate.Result) {
return
}
vr.Pass = true
vr.Msg = "commit subject is not more than 90 characters"
if len(c["subject"]) > 72 {
vr.Msg = "commit subject is not more than 90 characters, but is still more than 72 chars"
} else {
vr.Msg = "commit subject is 72 characters or less! *yay*"
}
return
}