diff --git a/internal/convention/option.go b/internal/convention/option.go index 50d82e8..7c52b5b 100644 --- a/internal/convention/option.go +++ b/internal/convention/option.go @@ -1,7 +1,6 @@ package convention import ( - "errors" "fmt" "regexp" "strings" @@ -10,21 +9,19 @@ import ( "github.com/haunt98/clock" ) -var ( - ErrEmptyCommit = errors.New("empty commit") - - headerRegex = regexp.MustCompile(`(?P[a-zA-Z]+)(?P\([a-zA-Z]+\))?(?P!)?:\s(?P.+)`) -) +var headerRegex = regexp.MustCompile(`(?P[a-zA-Z]+)(?P\([a-zA-Z]+\))?(?P!)?:\s(?P.+)`) type OptionFn func(*Commit) error func GetRawHeader(gitCommit git.Commit) OptionFn { return func(c *Commit) error { + // Skip empty commit + if gitCommit.Message == "" { + return nil + } + message := strings.TrimSpace(gitCommit.Message) messages := strings.Split(message, "\n") - if len(messages) == 0 { - return ErrEmptyCommit - } c.RawHeader = messages[0]