We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When commit-check is run with multiple checks, failures are overridden by passing checks that run after the failures.
commit-check
--message
hooks/commit-msg:
hooks/commit-msg
#!/bin/sh MESSAGE_FILE="$1" # check message only commit-check --message "$MESSAGE_FILE"
example commit:
git commit -m "unconventional commit with a bad message!"
Commit rejected by Commit-Check. (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) || E || || R || || R || || O || || R || _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ Commit rejected. Type message check failed => unconventional commit with a bad message! It doesn't match regex: ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*) The commit message should be structured as follows: <type>[optional scope]: <description> [optional body] [optional footer(s)] More details please refer to https://www.conventionalcommits.org Suggest: please check your commit message whether matches above regex
git log:
72b8ebc (HEAD -> main) feat: Initial commit
--author-name
#!/bin/sh MESSAGE_FILE="$1" # check message and author name commit-check --message --author-name "$MESSAGE_FILE"
Example commit:
$ git commit -m "unconventional commit with a bad message!"
Commit rejected by Commit-Check. (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) || E || || R || || R || || O || || R || _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ Commit rejected. Type message check failed => unconventional commit with a bad message! It doesn't match regex: ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*) The commit message should be structured as follows: <type>[optional scope]: <description> [optional body] [optional footer(s)] More details please refer to https://www.conventionalcommits.org Suggest: please check your commit message whether matches above regex [main 3601b27] unconventional commit with a bad message! 1 file changed, 4 insertions(+) create mode 100755 hooks/pre-commit
3601b27 (HEAD -> main) unconventional commit with a bad message! 72b8ebc feat: Initial commit
The source of the bug is here: https://github.com/commit-check/commit-check/blame/91ee12b3f5045523cbdacd07390c0ce98f3b8231/commit_check/main.py#L109-L124
Annotated with previous example:
def main() -> int: """The main entrypoint of commit-check program.""" parser = get_parser() args = parser.parse_args() retval = PASS with error_handler(): config = validate_config(args.config) if validate_config( args.config, ) else DEFAULT_CONFIG checks = config['checks'] if args.message: retval = commit.check_commit_msg(checks, args.commit_msg_file) # retval is now FAIL if args.author_name: retval = author.check_author(checks, "author_name") # retval is now PASS! Uh oh! if args.author_email: retval = author.check_author(checks, "author_email") if args.branch: retval = branch.check_branch(checks) if args.commit_signoff: retval = commit.check_commit_signoff(checks) if args.merge_base: retval = branch.check_merge_base(checks) if args.dry_run: retval = PASS return retval # returns PASS
commit-check 0.9.2
The text was updated successfully, but these errors were encountered:
Note that my example used commit-msg, so the author name is actually grabbed from the previous commit. A better example might be --check-signoff
commit-msg
--check-signoff
Either way, author-name's success (against the previous commit) still overrode a failed --message check.
author-name
Sorry, something went wrong.
Right. The source here: https://github.com/commit-check/commit-check/blame/91ee12b3f5045523cbdacd07390c0ce98f3b8231/commit_check/main.py#L109-L124 indeed looks like an obvious bug. Thanks for reporting and PR!
Successfully merging a pull request may close this issue.
describe your issue
When
commit-check
is run with multiple checks, failures are overridden by passing checks that run after the failures.Example running only
--message
, which fails as expected:hooks/commit-msg
:example commit:
git commit -m "unconventional commit with a bad message!"
git log:
Example running both
--message
and--author-name
(with name set in git config) which succeeds unexpectedly:hooks/commit-msg
:Example commit:
$ git commit -m "unconventional commit with a bad message!"
git log:
Cause
The source of the bug is here: https://github.com/commit-check/commit-check/blame/91ee12b3f5045523cbdacd07390c0ce98f3b8231/commit_check/main.py#L109-L124
Annotated with previous example:
commit-check version
commit-check 0.9.2
.commit-check.yml
The text was updated successfully, but these errors were encountered: