File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22package parser
33
44import (
5+ "errors"
56 "fmt"
67 "regexp"
78 "strings"
89)
910
11+ var (
12+ errHeader = errors .New ("unable to parse commit header" )
13+ errNoNewLine = errors .New ("commit description not followed by an empty line" )
14+ )
15+
1016// Commit represents a commit that adheres to the conventional commits specification
1117type Commit struct {
1218 Header Header
@@ -65,7 +71,7 @@ func Parse(message string) (*Commit, error) {
6571 }
6672 case 1 :
6773 if msgLine != "" {
68- return commit , fmt . Errorf ( "commit description not followed by an empty line" )
74+ return commit , errNoNewLine
6975 }
7076 default :
7177 key , value := parseLineAsFooter (msgLine )
@@ -146,7 +152,7 @@ func parseHeader(header string, commit *Commit) error {
146152 // TODO: comma separated multiple scopes?
147153 matches := headerRegexp .FindStringSubmatch (header )
148154 if matches == nil {
149- return fmt . Errorf ( "unable to parse commit header: %s" , header )
155+ return errHeader
150156 }
151157
152158 head := Header {
You can’t perform that action at this time.
0 commit comments