Skip to content

Commit 93098de

Browse files
aexvirkodiakhq[bot]
authored andcommitted
feat(parse): Make scope syntax less restrictive
1 parent 26a2a5c commit 93098de

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

parse_commit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
var (
1111
referenceFormatRegex = regexp.MustCompile(`Refs:?[^\r\n]*`)
1212
referenceIDFormatRegex = regexp.MustCompile(`\#([0-9]+)`)
13-
expectedFormatRegex = regexp.MustCompile(`(?s)^(?P<category>\w+?)?(?P<scope>\(\S+\))?(?P<breaking>!?)?: (?P<heading>[^\n\r]+)?([\n\r]{2}(?P<body>.*))?`)
13+
expectedFormatRegex = regexp.MustCompile(`(?s)^(?P<category>\w+?)?(?P<scope>\([^\)]+\))?(?P<breaking>!?)?: (?P<heading>[^\n\r]+)?([\n\r]{2}(?P<body>.*))?`)
1414
)
1515

1616
// GetIssueNumbers converts the matches from the reference regular expression to integers

parse_commit_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ func TestParseCommitMessage(t *testing.T) {
2121
"chore: test\n\nsomething more here\nRefs: #12 and #13": Commit{Category: "chore", Scope: "", Heading: "test", Body: "something more here", Issues: []int{12, 13}},
2222
"chore: add something\n": Commit{Category: "chore", Heading: "add something"},
2323
"chore(ci): added new CI stuff\n": Commit{Category: "chore", Scope: "ci", Heading: "added new CI stuff"},
24+
"chore(a b c d): added new CI stuff\n": Commit{Category: "chore", Scope: "a b c d", Heading: "added new CI stuff"},
25+
"chore(><(((*>): added new CI stuff\n": Commit{Category: "chore", Scope: "><(((*>", Heading: "added new CI stuff"},
2426
"feat: added a new feature\n": Commit{Category: "feat", Heading: "added a new feature"},
2527
"fix!: breaking change\n": Commit{Category: "fix", Breaking: true, Heading: "breaking change"},
2628
"fix(security)!: breaking\n": Commit{Category: "fix", Scope: "security", Breaking: true, Heading: "breaking"},
2729
"fix!!: breaking\n": Commit{Heading: "fix!!: breaking\n"},
28-
"fix(security)(stuff): should break\n": Commit{Category: "fix", Scope: "security(stuff)", Heading: "should break"},
30+
"fix(security)(stuff): should break\n": Commit{Heading: "fix(security)(stuff): should break\n"},
2931
"chore:really close\n": Commit{Heading: "chore:really close\n"},
3032
"perf(): nope\n": Commit{Heading: "perf(): nope\n"},
3133
"chore(: bad\n": Commit{Heading: "chore(: bad\n"},

0 commit comments

Comments
 (0)