Skip to content

Commit a038b41

Browse files
honzamelenaJan Melena
and
Jan Melena
authored
fix(cz-commitlint): combine commit body with issuesBody/breakingBody when body has an empty string (#2915)
Co-authored-by: Jan Melena <[email protected]>
1 parent 499efd1 commit a038b41

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

@commitlint/cz-commitlint/src/SectionBody.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,13 @@ describe('combineCommitMessage', () => {
7474
});
7575
expect(commitMessage).toBe('This is issue body message.');
7676
});
77+
78+
test('should use issueBody when body message is empty string but commit has issue note', () => {
79+
setRules({});
80+
const commitMessage = combineCommitMessage({
81+
body: '',
82+
issuesBody: 'This is issue body message.',
83+
});
84+
expect(commitMessage).toBe('This is issue body message.');
85+
});
7786
});

@commitlint/cz-commitlint/src/SectionBody.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function combineCommitMessage(answers: Answers): string {
1919
const leadingBlankFn = getLeadingBlankFn(getRule('body', 'leading-blank'));
2020
const {body, breakingBody, issuesBody} = answers;
2121

22-
const commitBody = body ?? breakingBody ?? issuesBody ?? '-';
22+
const commitBody = body || breakingBody || issuesBody || '-';
2323

2424
if (commitBody) {
2525
return leadingBlankFn(

0 commit comments

Comments
 (0)