mirror of
https://github.com/vbatts/git-validation.git
synced 2025-06-26 20:48:28 +00:00
*: fix typos and stuff
because that's what I do Signed-off-by: Jonathan Boulle <jon.boulle@coreos.com>
This commit is contained in:
parent
769b4028a4
commit
41062f1be2
3 changed files with 7 additions and 7 deletions
36
rules/shortsubject/shortsubject.go
Normal file
36
rules/shortsubject/shortsubject.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package shortsubject
|
||||
|
||||
import (
|
||||
"github.com/vbatts/git-validation/git"
|
||||
"github.com/vbatts/git-validation/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
// ShortSubjectRule 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)
|
||||
}
|
||||
|
||||
// ValidateShortSubject checks that the commit's subject is strictly less than
|
||||
// 90 characters (preferably not more than 72 chars).
|
||||
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
|
||||
if len(c["subject"]) > 72 {
|
||||
vr.Msg = "commit subject is under 90 characters, but is still more than 72 chars"
|
||||
} else {
|
||||
vr.Msg = "commit subject is 72 characters or less! *yay*"
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue