From 93098de466a78bfed6e92f25735e90a6505d1e99 Mon Sep 17 00:00:00 2001 From: Alex Viscreanu Date: Thu, 12 Mar 2020 12:21:29 +0100 Subject: [PATCH] feat(parse): Make scope syntax less restrictive --- parse_commit.go | 2 +- parse_commit_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/parse_commit.go b/parse_commit.go index 257fea5..3719042 100644 --- a/parse_commit.go +++ b/parse_commit.go @@ -10,7 +10,7 @@ import ( var ( referenceFormatRegex = regexp.MustCompile(`Refs:?[^\r\n]*`) referenceIDFormatRegex = regexp.MustCompile(`\#([0-9]+)`) - expectedFormatRegex = regexp.MustCompile(`(?s)^(?P\w+?)?(?P\(\S+\))?(?P!?)?: (?P[^\n\r]+)?([\n\r]{2}(?P.*))?`) + expectedFormatRegex = regexp.MustCompile(`(?s)^(?P\w+?)?(?P\([^\)]+\))?(?P!?)?: (?P[^\n\r]+)?([\n\r]{2}(?P.*))?`) ) // GetIssueNumbers converts the matches from the reference regular expression to integers diff --git a/parse_commit_test.go b/parse_commit_test.go index d642d53..b0d9998 100644 --- a/parse_commit_test.go +++ b/parse_commit_test.go @@ -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"},