From bb5e69b958c9dd4818c30315ae99d3ecc7e41fa1 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Tue, 1 Oct 2024 14:08:33 -0700 Subject: [PATCH] fix: when parsing multiple messages from a single commit, require 2 newlines (#2390) * fix: when parsing multiple messages from a single commit, require 2 newlines * test: fix test name * try optional windows newlines --- src/commit.ts | 2 +- test/commits.ts | 8 ++ test/fixtures/commit-messages/dependabot.txt | 102 +++++++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/commit-messages/dependabot.txt diff --git a/src/commit.ts b/src/commit.ts index 7645bfec5..904b24c0f 100644 --- a/src/commit.ts +++ b/src/commit.ts @@ -389,7 +389,7 @@ function splitMessages(message: string): string[] { const conventionalCommits = messages[0] .split( - /\n(?=(?:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.*?\))?: )/ + /\r?\n\r?\n(?=(?:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.*?\))?: )/ ) .filter(Boolean); return [...conventionalCommits, ...messages.slice(1)]; diff --git a/test/commits.ts b/test/commits.ts index 76c29183c..55ecdeacb 100644 --- a/test/commits.ts +++ b/test/commits.ts @@ -57,6 +57,14 @@ describe('parseConventionalCommits', () => { expect(conventionalCommits[1].scope).is.null; }); + it('can parse multiple commit messages requires 2 line breaks', async () => { + const commits = [buildCommitFromFixture('dependabot')]; + const conventionalCommits = parseConventionalCommits(commits); + expect(conventionalCommits).lengthOf(1); + expect(conventionalCommits[0].type).to.equal('fix'); + expect(conventionalCommits[0].scope).is.null; + }); + it('handles BREAKING CHANGE body', async () => { const commits = [buildCommitFromFixture('breaking-body')]; const conventionalCommits = parseConventionalCommits(commits); diff --git a/test/fixtures/commit-messages/dependabot.txt b/test/fixtures/commit-messages/dependabot.txt new file mode 100644 index 000000000..e167a1fd9 --- /dev/null +++ b/test/fixtures/commit-messages/dependabot.txt @@ -0,0 +1,102 @@ +fix: bump release-please from 16.13.0 to 16.14.0 (#1032) + +Bumps [release-please](https://github.com/googleapis/release-please) +from 16.13.0 to 16.14.0. +
+Release notes +

Sourced from release-please's +releases.

+
+

v16.14.0

+

16.14.0 +(2024-09-17)

+

Features

+
    +
  • handle multiple commits in a single message (#2358) +(ec41c38)
  • +
+
+
+
+Changelog +

Sourced from release-please's +changelog.

+
+

16.14.0 +(2024-09-17)

+

Features

+
    +
  • handle multiple commits in a single message (#2358) +(ec41c38)
  • +
+
+
+
+Commits + +
+
+ + +[![Dependabot compatibility +score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=release-please&package-manager=npm_and_yarn&previous-version=16.13.0&new-version=16.14.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) + +Dependabot will resolve any conflicts with this PR as long as you don't +alter it yourself. You can also trigger a rebase manually by commenting +`@dependabot rebase`. + +[//]: # (dependabot-automerge-start) +[//]: # (dependabot-automerge-end) + +--- + +
+Dependabot commands and options +
+ +You can trigger Dependabot actions by commenting on this PR: +- `@dependabot rebase` will rebase this PR +- `@dependabot recreate` will recreate this PR, overwriting any edits +that have been made to it +- `@dependabot merge` will merge this PR after your CI passes on it +- `@dependabot squash and merge` will squash and merge this PR after +your CI passes on it +- `@dependabot cancel merge` will cancel a previously requested merge +and block automerging +- `@dependabot reopen` will reopen this PR if it is closed +- `@dependabot close` will close this PR and stop Dependabot recreating +it. You can achieve the same result by closing it manually +- `@dependabot show ignore conditions` will show all +of the ignore conditions of the specified dependency +- `@dependabot ignore this major version` will close this PR and stop +Dependabot creating any more for this major version (unless you reopen +the PR or upgrade to it yourself) +- `@dependabot ignore this minor version` will close this PR and stop +Dependabot creating any more for this minor version (unless you reopen +the PR or upgrade to it yourself) +- `@dependabot ignore this dependency` will close this PR and stop +Dependabot creating any more for this dependency (unless you reopen the +PR or upgrade to it yourself) + + +
\ No newline at end of file