Skip to content

Commit

Permalink
Merge pull request #43 from zeroshade/breaking
Browse files Browse the repository at this point in the history
fix(internal/angular): fix angular parsing of breaking change messages that have multiple lines
  • Loading branch information
Nightapes authored Jul 28, 2020
2 parents cc22d5d + f0ebb03 commit 1bc0185
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/analyzer/angular.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ANGULAR = "angular"

func newAngular() *angular {
return &angular{
regex: `^(TAG)(?:\((.*)\))?: (.*)`,
regex: `^(TAG)(?:\((.*)\))?: (?s)(.*)`,
log: log.WithField("analyzer", ANGULAR),
rules: []Rule{
{
Expand Down Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions internal/analyzer/angular_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 1bc0185

Please sign in to comment.