-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Expose prepare-commit-msg arguments as environment vars #2407
Conversation
so it shouldn't treat them as arguments, pre-commit only deals in files they should be environment variables to match up with the other hooks |
Ah! I see what you mean now...
I have changed it accordingly. |
This was the most elegant way I thought of to keep this underneath the PEP8 line length. Maybe you have an opinion on this... if args.prepare_commit_message_source:
environ['PRE_COMMIT_COMMIT_MSG_SOURCE'] \
= args.prepare_commit_message_source I have implemented all the other name changes as you suggested. In regards to the tests: Do you usually extend the existing tests i.e. test_prepare_commit_msg_hook or do you want one for each different possible argument passed from the hook? |
even pep8 suggests using parens over backslashes:
and yeah there'll need to be new tests -- whatever is needed to demonstrate the change should be sufficient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, is there any documentation in pre-commit on these environment vars? |
@asottile Same problem, but with PRE_COMMIT_COMMIT_OBJECT_NAME @Konfekt did you resolve it? |
Hello, I think I got interested in it for a commit message generation script and resorted to detecting rebases by detecting more than one command-line argument https://gist.github.com/Konfekt/d9640c390deea4beafcf74e29410b8a6#file-chatgpt-write-msg-py-L8 but actually cannot remember at all |
Closes #2406.
This adds the ability to pass environ args that are not files to the prepare-commit-msg hook as defined by the git specification:
Git hook documentation
If you want some tests for this more than happy to think up some, however, I have tried to only add to existing code and use optional arguments so all existing tests are not affected.