Skip to content

cz check does not ignore comments #455

@lukehsiao

Description

@lukehsiao

Description

Many people utilize git commit templates as a starting point for writing their commit messages. One such template might look like

# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<----  Try to Limit to a Max of 50 char  ---->|


# Explain why this change is being made
# |<----   Try To Limit Each Line to a Maximum Of 72 Characters   ---->|

So, when utilized, the actual git commit message might look like

# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<----  Try to Limit to a Max of 50 char  ---->|
ci: add commitizen pre-commit hook

# Explain why this change is being made
# |<----   Try To Limit Each Line to a Maximum Of 72 Characters   ---->|
This pre-commit hook will check our commits automatically.

In the git log, this will appear as:

ci: add commitizen pre-commit hook

This pre-commit hook will check our commits automatically.

Because lines starting with # are comments.

Commitizen will incorrectly report this as an invalid commit message

Steps to reproduce

  1. Using commitizen pre-commit hooks, write a git commit where the first line is a comment.

Current behavior

Once the pre-commit hook runs, it will return something like:

commit validation: failed!
please enter a commit message in the commitizen format.
commit "": "# <type>: (If applied, this commit will...) <subject> (Max 50 char)

# |<----  Try to Limit to a Max of 50 char  ---->|
ci: add commitizen pre-commit hook

Desired behavior

This commit should be valid, because it conforms to convention commit standard.

Environment

cz version --report
Commitizen Version: 2.20.0
Python Version: 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0]
Operating System: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions