Skip to content

Commit

Permalink
fix(cz-commitlint): combine commit body with issuesBody/breakingBody …
Browse files Browse the repository at this point in the history
…when body has an empty string (#2915)

Co-authored-by: Jan Melena <jan.melena@productoo.com>
  • Loading branch information
honzamelena and Jan Melena committed Dec 11, 2021
1 parent 499efd1 commit a038b41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions @commitlint/cz-commitlint/src/SectionBody.test.ts
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
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

0 comments on commit a038b41

Please sign in to comment.