Skip to content

Commit

Permalink
feat(format): print full commit message for valid commits if -V (#4026)
Browse files Browse the repository at this point in the history
  • Loading branch information
weixinwu authored Apr 19, 2024
1 parent a8cbc0c commit a7bbc49
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
23 changes: 23 additions & 0 deletions @commitlint/format/src/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ test('returns empty summary if verbose', () => {
expect(actual).toContain('0 problems, 0 warnings');
});

test('returns empty summary with full commit message if verbose', () => {
const actual = format(
{
results: [
{
errors: [],
warnings: [],
input:
'feat(cli): this is a valid header\n\nThis is a valid body\n\nSigned-off-by: tester',
},
],
},
{
verbose: true,
color: false,
}
);

expect(actual).toStrictEqual(
'⧗ input: feat(cli): this is a valid header\n\nThis is a valid body\n\nSigned-off-by: tester\n✔ found 0 problems, 0 warnings'
);
});

test('returns a correct summary of empty .errors and .warnings', () => {
const actualError = format({
results: [
Expand Down
3 changes: 1 addition & 2 deletions @commitlint/format/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ function formatInput(

const sign = '⧗';
const decoration = enabled ? chalk.gray(sign) : sign;
const commitText = errors.length > 0 ? input : input.split('\n')[0];

const decoratedInput = enabled ? chalk.bold(commitText) : commitText;
const decoratedInput = enabled ? chalk.bold(input) : input;
const hasProblems = errors.length > 0 || warnings.length > 0;

return options.verbose || hasProblems
Expand Down

0 comments on commit a7bbc49

Please sign in to comment.