diff --git a/src/git.ts b/src/git.ts index 823ae66f..ddef33a6 100644 --- a/src/git.ts +++ b/src/git.ts @@ -107,11 +107,12 @@ export function parseGitCommit( } const type = match.groups.type; + const hasBreakingBody = /breaking change:/i.test(commit.body); let scope = match.groups.scope || ""; scope = config.scopeMap[scope] || scope; - const isBreaking = Boolean(match.groups.breaking); + const isBreaking = Boolean(match.groups.breaking || hasBreakingBody); let description = match.groups.description; // Extract references from message diff --git a/test/git.test.ts b/test/git.test.ts index 32b4d166..ac1f1f8e 100644 --- a/test/git.test.ts +++ b/test/git.test.ts @@ -151,6 +151,43 @@ describe("git", () => { ]); }); + test("parse commit with breaking body", async () => { + const rawCommitEmojiList = [ + { + message: "💥 feat: added a breaking change", + shortHash: "0000000", + body: "BREAKING CHANGE: added a breaking change.", + author: { + email: "jannchie@gmail.com", + name: "Jannchie", + }, + }, + ]; + const parsed = parseCommits( + rawCommitEmojiList, + await loadChangelogConfig(process.cwd(), {}) + ); + + expect( + parsed.map(({ body: _, author: __, authors: ___, ...rest }) => rest) + ).toMatchObject([ + { + message: "💥 feat: added a breaking change", + shortHash: "0000000", + description: "added a breaking change", + type: "feat", + scope: "", + references: [ + { + value: "0000000", + type: "hash", + }, + ], + isBreaking: true, + }, + ]); + }); + test("parse", async () => { const COMMIT_FROM = "1cb15d5dd93302ebd5ff912079ed584efcc6703b"; const COMMIT_TO = "3828bda8c45933396ddfa869d671473231ce3c95";