1
0
Fork 0
mirror of https://github.com/vbatts/git-validation.git synced 2025-01-29 22:57:33 +00:00

shortsubject: add a subject length check

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2015-10-05 19:02:31 -04:00
parent 5e74abd1b2
commit b9413c60c8
2 changed files with 31 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/vbatts/git-validation/git"
_ "github.com/vbatts/git-validation/rules/dco"
_ "github.com/vbatts/git-validation/rules/shortsubject"
"github.com/vbatts/git-validation/validate"
)

View file

@ -0,0 +1,30 @@
package shortsubject
import (
"github.com/vbatts/git-validation/git"
"github.com/vbatts/git-validation/validate"
)
var (
// DcoRule is the rule being registered
ShortSubjectRule = validate.Rule{
Name: "short-subject",
Description: "commit subjects are strictly less than 90 (github ellipsis length)",
Run: ValidateShortSubject,
}
)
func init() {
validate.RegisterRule(ShortSubjectRule)
}
func ValidateShortSubject(c git.CommitEntry) (vr validate.Result) {
if len(c["subject"]) >= 90 {
vr.Pass = false
vr.Msg = "commit subject exceeds 90 characters"
return
}
vr.Pass = true
vr.Msg = "commit subject is not more than 90 characters"
return
}