diff --git a/internal/analyzer/angular.go b/internal/analyzer/angular.go index fbfc36b..e9ce0b5 100644 --- a/internal/analyzer/angular.go +++ b/internal/analyzer/angular.go @@ -22,7 +22,7 @@ const ANGULAR = "angular" func newAngular() *angular { return &angular{ - regex: `^(TAG)(?:\((.*)\))?: (.*)`, + regex: `^(TAG)(?:\((.*)\))?: (?s)(.*)`, log: log.WithField("analyzer", ANGULAR), rules: []Rule{ { @@ -105,8 +105,8 @@ func (a *angular) analyze(commit shared.Commit, rule Rule) (shared.AnalyzedCommi } breakingChange := strings.SplitN(message, "BREAKING CHANGE:", 2) - analyzed.ParsedMessage = strings.Trim(breakingChange[0], " ") - analyzed.ParsedBreakingChangeMessage = strings.Trim(breakingChange[1], " ") + analyzed.ParsedMessage = strings.TrimSpace(breakingChange[0]) + analyzed.ParsedBreakingChangeMessage = strings.TrimSpace(breakingChange[1]) a.log.Tracef(" %s, BREAKING CHANGE found", commit.Message) return analyzed, true, nil diff --git a/internal/analyzer/angular_test.go b/internal/analyzer/angular_test.go index c719509..1076b72 100644 --- a/internal/analyzer/angular_test.go +++ b/internal/analyzer/angular_test.go @@ -93,6 +93,53 @@ func TestAngular(t *testing.T) { }, }, }, + { testCase: "feat breaking change footer", + commits: []shared.Commit{ + shared.Commit{ + Message: "feat(internal/changelog): my first commit", + Author: "me", + Hash: "12345667", + }, + shared.Commit{ + Message: "feat(internal/changelog): my first break \n\nBREAKING CHANGE: change api to v2\n", + Author: "me", + Hash: "12345668", + }, + }, + analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{ + "minor": []shared.AnalyzedCommit{ + shared.AnalyzedCommit{ + Commit: shared.Commit{ + Message: "feat(internal/changelog): my first commit", + Author: "me", + Hash: "12345667", + }, + Scope: "internal/changelog", + ParsedMessage: "my first commit", + Tag: "feat", + TagString: "Features", + Print: true, + }, + }, + "major": []shared.AnalyzedCommit{ + shared.AnalyzedCommit{ + Commit: shared.Commit{ + Message: "feat(internal/changelog): my first break \n\nBREAKING CHANGE: change api to v2\n", + Author: "me", + Hash: "12345668", + }, + Scope: "internal/changelog", + ParsedMessage: "my first break", + Tag: "feat", + TagString: "Features", + Print: true, + ParsedBreakingChangeMessage: "change api to v2", + }, + }, + "patch": []shared.AnalyzedCommit{}, + "none": []shared.AnalyzedCommit{}, + }, + }, { testCase: "invalid", analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{