0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-24 11:10:39 +00:00

refactor(validate-commit-message): print subject at validation error

issue: #11
This commit is contained in:
Beatriz Vieira 2021-02-25 22:40:07 -03:00
parent 29594212f3
commit 831f3a3723

View File

@ -2,7 +2,6 @@ package sv
import ( import (
"bufio" "bufio"
"errors"
"fmt" "fmt"
"regexp" "regexp"
"strings" "strings"
@ -81,7 +80,7 @@ func (p MessageProcessorImpl) Validate(message string) error {
msg := p.Parse(subject, body) msg := p.Parse(subject, body)
if !regexp.MustCompile("^[a-z+]+(\\(.+\\))?!?: .+$").MatchString(subject) { if !regexp.MustCompile("^[a-z+]+(\\(.+\\))?!?: .+$").MatchString(subject) {
return errors.New("message should be valid according with conventional commits") return fmt.Errorf("subject [%s] should be valid according with conventional commits", subject)
} }
if msg.Type == "" || !contains(msg.Type, p.messageCfg.Types) { if msg.Type == "" || !contains(msg.Type, p.messageCfg.Types) {