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

prepare-commit-msg Not passing all parameters #2406

M-Whitaker opened this issue May 27, 2022 · 2 comments · Fixed by #2407

prepare-commit-msg Not passing all parameters #2406

M-Whitaker opened this issue May 27, 2022 · 2 comments · Fixed by #2407


Copy link

search tried in the issue tracker


describe your issue

When I run git commit with certain arguments I expect to get two or more arguments passed to argv of my script as per the specification:


def main(argv, argc):
     print(argv, argc)

Will print

['tools/hooks/', '.git/COMMIT_EDITMSG'] 2

It looks to me from looking at your auto-created hook installed that you are passing all args to the script so it maybe I haven't configured this correctly.


pre-commit --version

pre-commit 2.19.0


   - repo:
        - id: commit-template-local
          name: Provide Commit Message Template
          entry: tools/hooks/
          language: python
          stages: [ prepare-commit-msg ]

~/.cache/pre-commit/pre-commit.log (if present)

No response

Copy link

yep -- pre-commit is based on files -- for now the additional non-file arguments are discarded

there's precedent for other hook types to forward these arguments along (for example PRE_COMMIT_REMOTE_NAME for pre-push) -- it looks like these were just not implemented for prepare-commit-msg

please send a patch to add those if you'd like support for those as environment variables -- I'd grep around for PRE_COMMIT_REMOTE_NAME and follow the pattern used there

Copy link
Contributor Author

Ah, perfect I'm not going crazy. I'll have a look into this 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

2 participants