diff --git a/@commitlint/cz-commitlint/src/SectionBody.test.ts b/@commitlint/cz-commitlint/src/SectionBody.test.ts index 12e4acc6e5..161b548989 100644 --- a/@commitlint/cz-commitlint/src/SectionBody.test.ts +++ b/@commitlint/cz-commitlint/src/SectionBody.test.ts @@ -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.'); + }); }); diff --git a/@commitlint/cz-commitlint/src/SectionBody.ts b/@commitlint/cz-commitlint/src/SectionBody.ts index de528b8858..1ea38bf6c0 100644 --- a/@commitlint/cz-commitlint/src/SectionBody.ts +++ b/@commitlint/cz-commitlint/src/SectionBody.ts @@ -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(