Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(format): print full commit message for valid commits if -V #4026

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
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