Sharmila Jesupaul
635912514d
add pass_filenames_via_stdin for large changesets
...
pre-commit currently passes selected filenames to hooks via argv.
For large changesets (or --all-files), argv length limits are hit and
filenames are partitioned, causing multiple hook invocations.
This means there is currently no built-in way to pass filenames to an
underlying hook in one shot without chunking / re-running. The only practical
workaround is to set pass_filenames: false and run custom git operations in
hook code to reconstruct the file set, which is expensive and duplicates
pre-commit's own file-selection logic.
This change adds a hook option:
pass_filenames_via_stdin: true
When enabled, pre-commit sends filenames as NUL-delimited bytes on stdin and
runs the hook in a single invocation (no argv chunking).
Why NUL-delimited stdin:
- safe for filenames containing spaces/newlines
- matches established -0 conventions in unix tooling
Usage for hook authors:
- shell:
while IFS= read -r -d '' filename; do
...
done
- python:
data = sys.stdin.buffer.read()
filenames = [os.fsdecode(p) for p in data.split(b'\0') if p]
Behavior notes:
- default remains argv-based passing
- pass_filenames: false still disables filename passing entirely
Implementation includes schema/runtime wiring, shared NUL encode/decode
helpers, and tests covering defaulting and runtime behavior.
2026-02-18 18:06:34 -08:00
anthony sottile
bdf68790b7
add pre-commit hazmat
2025-11-22 13:53:53 -05:00
anthony sottile
725acc969a
rename system and script languages to unsupported / unsupported_script
2025-11-08 15:09:16 -05:00
anthony sottile
8bbfcf1f82
remove redundant system spaces test
...
`test_args_with_spaces_and_quotes` also covers this behaviour
2025-11-08 13:16:38 -05:00
Anthony Sottile
801b956304
remove deprecated python_venv alias
2024-10-05 13:30:25 -04:00
Anthony Sottile
1d2f1c0cce
replace log_info_mock with pytest's caplog
2024-09-30 19:58:16 -04:00
Anthony Sottile
047439abff
attempt minimum_pre_commit_version first when parsing configs
2023-12-09 15:34:16 -05:00
marsha
d3c0a66d23
move slowest python-specific tests out of repository_test
2023-03-12 08:24:38 -05:00
Marcelo Galigniana
f39154f69f
Add pre-rebase hook support
2023-03-11 15:17:42 -05:00
Anthony Sottile
e3e17a1617
make --hook-type and stages match
2023-03-11 14:26:14 -05:00
marsha
63a180a935
rewrite args with spaces test to not require python
2023-03-09 00:41:27 -06:00
marsha
5ce4a549d3
prefer sys.platform over os.name when checking for windows OS
2023-03-03 22:13:07 -06:00
Anthony Sottile
d23990cc8b
use run_language for repository_test
2023-02-20 22:21:31 -05:00
Anthony Sottile
4f6ba18cad
Merge pull request #2767 from pre-commit/test-more-directly
...
test things more directly to improve coverage
2023-02-20 18:52:11 -05:00
Anthony Sottile
c3613b954a
test things more directly to improve coverage
2023-02-20 18:18:08 -05:00
Anthony Sottile
d3883ce7f7
move languages.all and languages.helpers out of languages
2023-02-20 18:03:45 -05:00
marsha
a2373d0a81
test pygrep inline
2023-02-18 17:54:44 -05:00
marsha
4fdfb25a52
test fail language inline
2023-02-13 17:03:59 -06:00
marsha
915b930a5d
test dotnet directly
2023-02-07 21:47:26 -06:00
marsha
6804100701
test golang directly
2023-02-06 17:02:20 -06:00
Anthony Sottile
0afb95ccca
test docker and docker_image directly
2023-02-04 17:22:06 -05:00
Anthony Sottile
0c1267b214
deprecate python_venv language
2023-02-04 14:26:09 -05:00
Anthony Sottile
909dd0e8a1
test node directly
2023-01-31 21:13:11 -05:00
Anthony Sottile
5b50acbd2c
test ruby directly
2023-01-30 21:36:13 -05:00
Anthony Sottile
77b4ea38ca
Merge pull request #2729 from pre-commit/rust-tests
...
test rust directly
2023-01-29 19:00:09 -05:00
Anthony Sottile
2adca78c6f
test rust directly
2023-01-29 18:27:10 -05:00
Anthony Sottile
420902f67c
fix r local hooks
...
`language: r` acts more like `language: script` so we have to *not* append
the prefix when run with `repo: local`
2023-01-29 17:27:42 -05:00
Anthony Sottile
6e8051b9e6
speed up ruby tests by picking a prebuilt in 22.04
2023-01-28 18:36:35 -05:00
Anthony Sottile
bff5e0e738
introduce install state v2 to replace v1
...
the v1 state is unnecessary since new repos are created for new additional_dependencies
2023-01-23 19:58:48 -05:00
Anthony Sottile
50848aaca2
Merge pull request #2709 from pre-commit/test-lua
...
test lua directly
2023-01-18 00:12:28 -05:00
Anthony Sottile
f042540311
test lua directly
2023-01-17 23:43:31 -05:00
Anthony Sottile
7512e3b7e1
test r language directly
2023-01-17 23:25:00 -05:00
Anthony Sottile
043565d28a
test dart directly
2023-01-17 18:44:14 -05:00
Anthony Sottile
d24055cb40
test perl language directly
2023-01-17 17:34:04 -05:00
Anthony Sottile
c36f03cd2e
test swift language directly
2023-01-17 13:51:06 -05:00
Anthony Sottile
f1b5f66374
test conda language directly
2023-01-17 13:05:49 -05:00
Anthony Sottile
70bfd76ced
coursier: additional_dependencies support
2023-01-17 09:59:04 -05:00
Anthony Sottile
628c876b2d
adjust the run_hook api to no longer take Hook
2023-01-16 16:34:01 -05:00
Anthony Sottile
ae34a962d7
make in_env part of the language api
2023-01-16 15:36:29 -05:00
taoufik07
9afd63948e
Make Go a first class language
2023-01-13 12:42:57 -05:00
Anthony Sottile
05c8911363
simplify environment_dir
2023-01-01 21:11:56 -05:00
Anthony Sottile
40e69ce8e3
use modules as protocols
2022-12-27 11:46:11 -05:00
Ruairidh MacLeod
e904628830
fix dotnet hooks with prefixes
2022-12-21 13:35:19 -05:00
Anthony Sottile
b00c31cf9e
use a newer version of ruby which builds cleanly
2022-12-12 12:22:39 -05:00
Anthony Sottile
b92fe01755
force the -p branch to run for language: python under test
2022-12-10 23:33:20 -05:00
Anthony Sottile
0b45ecc8a4
remove python 2.x cross version tests
2022-12-06 17:36:57 -05:00
marsha
e703982de4
Change Rust to install environment with cargo add over toml
2022-10-28 21:32:52 -05:00
Jan Holthuis
eb469c756d
Rust as 1st class language
2022-10-10 20:05:36 -04:00
Paul Gey
a54391e96f
Force gem installation into GEM_HOME
...
When `--user-install` is set in the gemrc config file, `gem` ignores
`GEM_HOME`. `--no-user-install` prevents this behaviour.
2022-05-07 20:44:02 +02:00
Anthony Sottile
3929fe4a63
upgrade CI to ubuntu-latest / windows-latest
2022-04-24 19:10:09 -04:00