Skip to content

Commit a7bbc49

Browse files
authored
feat(format): print full commit message for valid commits if -V (#4026)
1 parent a8cbc0c commit a7bbc49

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

@commitlint/format/src/format.test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,29 @@ test('returns empty summary if verbose', () => {
3535
expect(actual).toContain('0 problems, 0 warnings');
3636
});
3737

38+
test('returns empty summary with full commit message if verbose', () => {
39+
const actual = format(
40+
{
41+
results: [
42+
{
43+
errors: [],
44+
warnings: [],
45+
input:
46+
'feat(cli): this is a valid header\n\nThis is a valid body\n\nSigned-off-by: tester',
47+
},
48+
],
49+
},
50+
{
51+
verbose: true,
52+
color: false,
53+
}
54+
);
55+
56+
expect(actual).toStrictEqual(
57+
'⧗ 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'
58+
);
59+
});
60+
3861
test('returns a correct summary of empty .errors and .warnings', () => {
3962
const actualError = format({
4063
results: [

@commitlint/format/src/format.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ function formatInput(
4242

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

47-
const decoratedInput = enabled ? chalk.bold(commitText) : commitText;
46+
const decoratedInput = enabled ? chalk.bold(input) : input;
4847
const hasProblems = errors.length > 0 || warnings.length > 0;
4948

5049
return options.verbose || hasProblems

0 commit comments

Comments
 (0)