0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-06-03 03:49:39 +02:00

refactor: handle parse errors to the caller in validate

issue: #45
This commit is contained in:
hypervtechnics 2022-04-06 09:52:35 +02:00
parent 25458f20f6
commit f36433692d

View File

@ -81,7 +81,11 @@ func (p MessageProcessorImpl) SkipBranch(branch string, detached bool) bool {
// Validate commit message.
func (p MessageProcessorImpl) Validate(message string) error {
subject, body := splitCommitMessageContent(message)
msg, _ := p.Parse(subject, body)
msg, parseErr := p.Parse(subject, body)
if (parseErr != nil) {
return parseErr
}
if !regexp.MustCompile(`^[a-z+]+(\(.+\))?!?: .+$`).MatchString(subject) {
return fmt.Errorf("subject [%s] should be valid according with conventional commits", subject)