Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions test/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
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";
Expand Down