Describe the bug
While trying to run pre-commit as a post-write hooks, I encountered a failure. My config was
hooks = pre-commit
pre-commit.type = console_scripts
pre-commit.entrypoint = pre-commit
pre-commit.options = run --files
The failure occurred because the pre-commit command was being run as
pre-commit /path/to/revision_file.py run --files
instead of
pre-commit run --files /path/to/revision_file.py
Expected behavior
The documentation states:
The path of the revision file is sent as a single positional argument to the script after the options.
However, checking the code, this is not the case, as it is being passed as the first argument.
Additional note
The command line options are being split using str.split(), but for command line options it's much better to use shlex.split() since that properly handles things like quoting.
PR incoming...
Describe the bug
While trying to run
pre-commitas a post-write hooks, I encountered a failure. My config wasThe failure occurred because the pre-commit command was being run as
instead of
Expected behavior
The documentation states:
However, checking the code, this is not the case, as it is being passed as the first argument.
Additional note
The command line options are being split using
str.split(), but for command line options it's much better to useshlex.split()since that properly handles things like quoting.PR incoming...