Skip to content

Commit

Permalink
feat: add check for breaking changes in commit body (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
itpropro authored Sep 28, 2024
1 parent 672848e commit 9dc3632
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
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

0 comments on commit 9dc3632

Please sign in to comment.