BUG: if used with pre-commit and additional args -> Invalid value for "--msg-filename"
See original GitHub issueWhen I use gitlint with pre-commit and want to add --extra-path
for custom rules like so:
repos:
- repo: https://github.com/jorisroovers/gitlint
rev: c359748723a52f6c0c5f87c3b71749f75179ca74 # frozen: v0.14.0
hooks:
- id: gitlint
args: [--extra-path pre-commit-helper.py]
I get the error:
gitlint..................................................................Failed
- hook id: gitlint
- exit code: 253
Usage: gitlint [OPTIONS] COMMAND [ARGS]...
Try "gitlint --help" for help.
Error: Invalid value for "--msg-filename": Could not open file: --extra-path pre-commit-helper.py: No such file or directory
*** Exit Code: 1 ***
Reason for this is that my added args [--extra-path pre-commit-helper.py]
are appended to the end after the entry-point. In gitlint’s .pre-commit-hooks.yaml
the entry contains args and --msg-filename
as one expects a value to follow.
As a workaround you have to overwrite the entry in .pre-commit-config.yaml
like so:
- repo: https://github.com/jorisroovers/gitlint
rev: c359748723a52f6c0c5f87c3b71749f75179ca74 # frozen: v0.14.0
hooks:
- id: gitlint
entry: gitlint
args: [--extra-path, pre-commit-helper.py, --staged, --msg-filename]
As a fix you have to move the args from entry
to args
. I will submit a PR.
Sure you then have to specify them again, if you overwrite them, but that gives you more granular control as a user and its cleaner IMHO.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
pre-commit hook fails when adding args · Issue #109 - GitHub
I've set up my .pre-commit-config.yml like this: default_stages: [commit ... Error: Invalid value for "--msg-filename": Could not open file: ...
Read more >pre-commit
We built pre-commit to solve our hook issues. It is a multi-language package manager for pre-commit hooks. You specify a list of hooks...
Read more >How to solve pre-commit asserttion error on ubuntu 22.04
I have installed a Django project with the cookie-cutter. and now I have got an error when I want to commit my changes....
Read more >Usage — pydocstyle 6.1.1 documentation
Options: --version show program's version number and exit -h, --help show this help message and exit -e, --explain show explanation of each error...
Read more >Improve Code Quality with Git Hooks and Pre-commit
Pre -commit hooks tutorial to improve code quality and reduce bugs. ... of this post for an example .pre-commit-config.yaml file I use as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So I looked into it and to be 100% sure I tested it with my PR-fork also: With the current
.pre-commit-hookss.yaml
you are 100% right. You have to specify both:entry
andargs
if you want to add customargs
to the hook. But if you work with my PR-version you only need to specify theargs
section and don’t need to specifyentry
also, because its just the vanilla command without any argument. So you don’t have to overwrite it.In both cases you have to add the
--msg-filename
argument at the end of cause.IMHO the PR-version is less confusing and I would also state it more explicit that one have to add
--msg-filename
toargs
if one overwrites them.If you want to take the PR I would also update the docs, if you want.
My bad. I use pre-commit for some time so I skipped this part.
I will look into it probably tomorrow.