Skip to content
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
feat(format): print full commit message for valid commits if -V
  • Loading branch information
weixinwu committed Apr 15, 2024
commit dec4f01595e537e055aa5c514f9935cb372c6351
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