Skip to content

feature request(cli): print body and footer for valid commits if “--verbose” command-line argument #3830

Closed
@Kristinita

Description

@Kristinita

1. Summary

It would be nice if Commitlint will print full commit, including body and footer, if commit is valid and --verbose flag is added to Commitlint command.

I think this would make adding Commitlint commands to the project clearer.

2. MCVE

2.1. Commit

git add .

git commit -m "feat(kiraexamplescope): This is a valid header" -m "This is a valid body" --signoff

2.2. Commitlint commands

npx commitlint --from=HEAD~1 --verbose

or

git log -1 --pretty=format:"%s%n%n%B" | npx commitlint --verbose

or if simple-git-hooks activated:

module.exports = {
	"commit-msg": "npx --no -- commitlint --edit \"$1\" --verbose"
};

3. Behavior

3.1. Actual

# [NOTE] I also think it would be nice to separate the word “input” with a blank line,
# because users might think it’s a name of the commit message typeinput: feat(kiraexamplescope): This is a valid header
✔   found 0 problems, 0 warnings

3.2. Expected

Input:

feat(kiraexamplescope): This is a valid header

This is a valid body

Signed-off-by: Kristinita <17247677+Kristinita@users.noreply.github.com>

✔	found 0 problems, 0 warnings

4. Explanation of the need for feature

If the commit is non-valid, Commitlint prints body and footer:

git commit -m "This is a non-valid header" -m "This is a valid body" --signoff
⧗   input: This is a non-valid header

This is a valid body

Signed-off-by: Kristinita <17247677+Kristinita@users.noreply.github.com>
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]
✖   scope may not be empty [scope-empty]

✖   found 3 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

But if the commit is valid, Commitlint prints solely the header. This distinction can be confusing when user add Commitlint commands to a project. When I set up my Commitlint commands, I thought I had set up my Commitlint commands so that Commitlint parsed solely the header. I spent my time unsuccessfully trying to configure Commitlint to parse the body and footer, until I realized that Commitlint already parses the body and footer if I use the commands I provided in the “Commitlint commands” section, but for some reason it doesn’t print the full contents of the commits.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions