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

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

prepare-commit-msg Not passing all parameters #2406

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

Comments

@M-Whitaker
Copy link
Contributor

search tried in the issue tracker

Yes

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:

image

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

Will print

['tools/hooks/add-commit-template.py', '.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.

Thanks

pre-commit --version

pre-commit 2.19.0

.pre-commit-config.yaml

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

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

No response

@asottile
Copy link
Member

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

@M-Whitaker
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
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants