Skip to content

fix(cz-commitlint): combine commit body with issuesBody/breakingBody … #2915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2021
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
9 changes: 9 additions & 0 deletions @commitlint/cz-commitlint/src/SectionBody.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,13 @@ describe('combineCommitMessage', () => {
});
expect(commitMessage).toBe('This is issue body message.');
});

test('should use issueBody when body message is empty string but commit has issue note', () => {
setRules({});
const commitMessage = combineCommitMessage({
body: '',
issuesBody: 'This is issue body message.',
});
expect(commitMessage).toBe('This is issue body message.');
});
});
2 changes: 1 addition & 1 deletion @commitlint/cz-commitlint/src/SectionBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function combineCommitMessage(answers: Answers): string {
const leadingBlankFn = getLeadingBlankFn(getRule('body', 'leading-blank'));
const {body, breakingBody, issuesBody} = answers;

const commitBody = body ?? breakingBody ?? issuesBody ?? '-';
const commitBody = body || breakingBody || issuesBody || '-';

if (commitBody) {
return leadingBlankFn(
Expand Down