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

pre-commit hook fails when adding args #109

Closed
sanzoghenzo opened this issue Nov 7, 2019 · 1 comment
Closed

pre-commit hook fails when adding args #109

sanzoghenzo opened this issue Nov 7, 2019 · 1 comment
Labels
docs Documentation related items question

Comments

@sanzoghenzo
Copy link

sanzoghenzo commented Nov 7, 2019

Hi,
I just found this great project and I would like to use it with pre-commit to enforce conventional commit style messages.

I've set up my .pre-commit-config.yml like this:

default_stages: [commit, push]
repos:
  # many other commit hooks here...
  - repo: https://github.com/jorisroovers/gitlint
    rev: v0.12.0
    hooks:
    -   id: gitlint
        stages: [commit-msg]
        args: [--contrib=CT1]

and correctly installed the hooks.

When I try to commit something, I get

gitlint..................................................................Failed
hookid: gitlint

Usage: gitlint [OPTIONS] COMMAND [ARGS]...
Try "gitlint --help" for help.

Error: Invalid value for "--msg-filename": Could not open file: --contrib=CT1: No such file or directory

This is because of how arguments are passed by pre-commit.

The workaround is overriding the hook entry and putting --msg-filename at the end of the args:

  - repo: https://github.com/jorisroovers/gitlint
    rev: v0.12.0
    hooks:
    -   id: gitlint
        stages: [commit-msg]
        entry: gitlint
        args: [--contrib=CT1, --msg-filename]

Not sure how it can be solved without major changes involving passing the commit file as positional argument.

@jorisroovers
Copy link
Owner

jorisroovers commented Nov 7, 2019

Thanks for your interest :-)

TIL, I didn't know this! I agree that working around this is probably not that easy. Sounds more like something we should document in the gitlint pre-commit docs section.

Alternatively, I think using a .gitlint file to specify contrib should also work.

@jorisroovers jorisroovers added docs Documentation related items question labels Nov 13, 2019
jorisroovers added a commit that referenced this issue Feb 26, 2020
- Patch to enable --staged flag for pre-commit.
- Minor doc updates #109

Full Release details in CHANGELOG.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related items question
Projects
None yet
Development

No branches or pull requests

2 participants