Skip to content

Commit

Permalink
feat(parse): Make scope syntax less restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
aexvir authored and kodiakhq[bot] committed Mar 12, 2020
1 parent 26a2a5c commit 93098de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parse_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
var (
referenceFormatRegex = regexp.MustCompile(`Refs:?[^\r\n]*`)
referenceIDFormatRegex = regexp.MustCompile(`\#([0-9]+)`)
expectedFormatRegex = regexp.MustCompile(`(?s)^(?P<category>\w+?)?(?P<scope>\(\S+\))?(?P<breaking>!?)?: (?P<heading>[^\n\r]+)?([\n\r]{2}(?P<body>.*))?`)
expectedFormatRegex = regexp.MustCompile(`(?s)^(?P<category>\w+?)?(?P<scope>\([^\)]+\))?(?P<breaking>!?)?: (?P<heading>[^\n\r]+)?([\n\r]{2}(?P<body>.*))?`)
)

// GetIssueNumbers converts the matches from the reference regular expression to integers
Expand Down
4 changes: 3 additions & 1 deletion parse_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ func TestParseCommitMessage(t *testing.T) {
"chore: test\n\nsomething more here\nRefs: #12 and #13": Commit{Category: "chore", Scope: "", Heading: "test", Body: "something more here", Issues: []int{12, 13}},
"chore: add something\n": Commit{Category: "chore", Heading: "add something"},
"chore(ci): added new CI stuff\n": Commit{Category: "chore", Scope: "ci", Heading: "added new CI stuff"},
"chore(a b c d): added new CI stuff\n": Commit{Category: "chore", Scope: "a b c d", Heading: "added new CI stuff"},
"chore(><(((*>): added new CI stuff\n": Commit{Category: "chore", Scope: "><(((*>", Heading: "added new CI stuff"},
"feat: added a new feature\n": Commit{Category: "feat", Heading: "added a new feature"},
"fix!: breaking change\n": Commit{Category: "fix", Breaking: true, Heading: "breaking change"},
"fix(security)!: breaking\n": Commit{Category: "fix", Scope: "security", Breaking: true, Heading: "breaking"},
"fix!!: breaking\n": Commit{Heading: "fix!!: breaking\n"},
"fix(security)(stuff): should break\n": Commit{Category: "fix", Scope: "security(stuff)", Heading: "should break"},
"fix(security)(stuff): should break\n": Commit{Heading: "fix(security)(stuff): should break\n"},
"chore:really close\n": Commit{Heading: "chore:really close\n"},
"perf(): nope\n": Commit{Heading: "perf(): nope\n"},
"chore(: bad\n": Commit{Heading: "chore(: bad\n"},
Expand Down

0 comments on commit 93098de

Please sign in to comment.