diff --git a/dev-infra/commit-message/parse.spec.ts b/dev-infra/commit-message/parse.spec.ts index 4fa8b623cd..e7f6924fa6 100644 --- a/dev-infra/commit-message/parse.spec.ts +++ b/dev-infra/commit-message/parse.spec.ts @@ -135,6 +135,15 @@ describe('commit message parsing:', () => { expect(parsedMessage.breakingChanges[0].text).toBe(`${summary}\n\n${description}`); expect(parsedMessage.breakingChanges.length).toBe(1); }); + + it('only when keyword is at the beginning of a line', () => { + const message = buildCommitMessage({ + body: 'This changes how the `BREAKING CHANGE: ` commit message note\n' + + 'keyword is detected for the changelog.', + }); + const parsedMessage = parseCommitMessage(message); + expect(parsedMessage.breakingChanges.length).toBe(0); + }); }); describe('parses deprecation notes', () => { @@ -168,5 +177,14 @@ describe('commit message parsing:', () => { expect(parsedMessage.deprecations[0].text).toBe(`${summary}\n\n${description}`); expect(parsedMessage.deprecations.length).toBe(1); }); + + it('only when keyword is at the beginning of a line', () => { + const message = buildCommitMessage({ + body: 'This changes how the `DEPRECATED: ` commit message note\n' + + 'keyword is detected for the changelog.', + }); + const parsedMessage = parseCommitMessage(message); + expect(parsedMessage.deprecations.length).toBe(0); + }); }); }); diff --git a/dev-infra/commit-message/parse.ts b/dev-infra/commit-message/parse.ts index 1892121a0e..0cebcc8913 100644 --- a/dev-infra/commit-message/parse.ts +++ b/dev-infra/commit-message/parse.ts @@ -111,7 +111,7 @@ const parseOptions: Options&{notesPattern: (keywords: string) => RegExp} = { headerPattern, headerCorrespondence, noteKeywords: [NoteSections.BREAKING_CHANGE, NoteSections.DEPRECATED], - notesPattern: (keywords: string) => new RegExp(`(${keywords}): ?(.*)`), + notesPattern: (keywords: string) => new RegExp(`^\s*(${keywords}): ?(.*)`), }; /** Parse a commit message into its composite parts. */ diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index 0d27dd2800..dc1c8e5ddf 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -1843,7 +1843,7 @@ const parseOptions = { headerPattern, headerCorrespondence, noteKeywords: [NoteSections.BREAKING_CHANGE, NoteSections.DEPRECATED], - notesPattern: (keywords) => new RegExp(`(${keywords}): ?(.*)`), + notesPattern: (keywords) => new RegExp(`^\s*(${keywords}): ?(.*)`), }; /** Parse a commit message into its composite parts. */ const parseCommitMessage = parseInternal;