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
844dacc168
add forward-compat error message
2025-11-19 14:57:01 -05:00
anthony sottile
725acc969a
rename system and script languages to unsupported / unsupported_script
2025-11-08 15:09:16 -05:00
anthony sottile
aa2961c122
fix missing context in error for stages
2025-11-08 14:31:15 -05:00
Anthony Sottile
33e020f315
add warning for deprecated stages values in default_stages
2024-09-30 19:22:14 -04:00
Anthony Sottile
7441a62eb1
add warning for deprecated stages names
2024-09-30 18:41:13 -04:00
Anthony Sottile
fa08d1d637
also apply sensible regex warning for repo: meta
2024-09-30 18:09:04 -04:00
Anthony Sottile
047439abff
attempt minimum_pre_commit_version first when parsing configs
2023-12-09 15:34:16 -05:00
Anthony Sottile
e3e17a1617
make --hook-type and stages match
2023-03-11 14:26:14 -05:00
Anthony Sottile
5425c754a0
move parse_version to pre_commit.clientlib
2023-01-01 17:17:00 -05:00
Anthony Sottile
848a73ed40
Merge pull request #2658 from pre-commit/remove-pre-commit-validate
...
remove pre-commit-validate-config and pre-commit-validate-manifest
2022-12-27 13:53:10 -05:00
Anthony Sottile
4a50859936
remove pre-commit-validate-config and pre-commit-validate-manifest
2022-12-27 13:05:30 -05:00
Anthony Sottile
def3fa3929
Merge pull request #2657 from pre-commit/remove-sha-support
...
remove support for sha to specify rev
2022-12-27 12:13:26 -05:00
Anthony Sottile
ff3150d58a
remove support for sha to specify rev
2022-12-27 11:29:00 -05:00
Anthony Sottile
0024484f5b
remove support for top-level list format
2022-12-27 11:15:45 -05:00
chrisRedwine
6d5de9feaf
remove extraneous raw string literal in test
2022-09-26 17:53:14 -05:00
chrisRedwine
a95f488e71
extend warning if globs are used instead of regex to local hooks
2022-09-25 11:56:04 -05:00
Anthony Sottile
777ffdd692
deprecate pre-commit-validate-{config,manifest}
2022-04-24 19:08:47 -04:00
Anthony Sottile
04de6a2e57
drop python 3.6 support
...
python 3.6 reached end of life on 2021-12-23
2022-01-18 18:44:20 -05:00
Anthony Sottile
d3b4f737b9
forbid overriding entry for meta hooks
2021-12-31 17:31:12 -08:00
Tony Rintala
d4ffa5befb
fix: Add missing warning for regular expression with [\\/]
...
test: Test case parameters for said regular expression
refactor: For-loop for regex warnings instead of multiple if statements
resolves #2151
2021-12-04 22:51:04 +02:00
Radek SPRTA
cef9c4af03
Add warning for regular expression with [\/] ( #2043 )
2021-09-22 19:07:38 -04:00
Anthony Sottile
f963bf6f9a
make repo: meta only apply to top level configuration
2021-08-28 13:39:55 -04:00
pre-commit-ci[bot]
d3c5cd6ee2
[pre-commit.ci] auto fixes from pre-commit.com hooks
...
for more information, see https://pre-commit.ci
2021-05-24 17:20:17 +00:00
Jam M. Hernandez Quiceno
3d31858ee3
Instruct users how to prevent a mutable rev in repo warning.
2021-02-23 17:59:50 -08:00
Paul Fischer
b1a9209f9f
extended warning if globs are used instead of regex to top level
2021-01-01 23:57:24 +01:00
Paul Fischer
1e4de986a8
added warning if mutable rev is used
2020-12-18 12:20:21 -08:00
Anthony Sottile
38a4a0aa3b
allow configuration for pre-commit.ci
2020-12-16 20:21:33 -08:00
Paul Fischer
610716d3d1
added warning if globs are used instead of regex
2020-11-22 18:53:48 -08:00
Anthony Sottile
68510596d3
warn on old list-style configuration
2020-07-25 13:04:54 -07:00
Anthony Sottile
9000e9dd41
Some manual .format() -> f-strings
2020-01-12 13:39:53 -08:00
Anthony Sottile
30c1e8289f
upgrade hooks, pyupgrade pre-commit
2020-01-12 09:27:04 -08:00
Anthony Sottile
625750eeef
fixes for cfgv>=2
2019-05-27 13:37:49 -07:00
Yoav Caspi
ba7760b705
Add a test to validate that cfgv.WarnAdditionalKeys working as expected in the relevant config schemas
2019-05-12 15:09:15 +03:00
Yoav Caspi
217d31ec1c
Add a check and test to the real top level and improve the warning message
2019-05-11 22:57:52 +03:00
Yoav Caspi
fd9d9d276b
Add warning to additional keys in config
2019-05-11 20:59:34 +03:00
Anthony Sottile
dc28922ccb
Run pre-commit autoupdate
...
Committed via https://github.com/asottile/all-repos
2019-03-21 21:09:33 -07:00
Anthony Sottile
c78b6967cd
Add top level minimum_pre_commit_version
2019-03-21 18:29:17 -07:00
Anthony Sottile
bea33af310
small cleanups in tests
2019-01-06 12:08:52 -08:00
Anthony Sottile
d3b5a41830
Implement default_language_version
2019-01-05 13:15:23 -08:00
Anthony Sottile
fc84567923
Default local / meta through cfgv
2019-01-05 08:31:03 -08:00
Anthony Sottile
9e34e6e316
pre-commit gc
2019-01-02 19:07:23 -08:00
Anthony Sottile
e4cf5f321b
just use normal dicts in tests
2018-12-31 11:15:22 -08:00
Anthony Sottile
5651c66995
Migrate sha -> rev
2018-02-24 20:19:39 -08:00
Anthony Sottile
bdad930d71
Move pre_commit.schema to cfgv library
2018-02-18 15:25:53 -08:00
Anthony Sottile
3e76cdaf25
Enable map configurations (config v2).
2017-09-06 10:01:08 -07:00
Anthony Sottile
3e3932d5a6
Upgrade add-trailing-comma to 0.5.1
2017-07-17 17:39:55 -07:00
Anthony Sottile
be3fbdf94e
Upgrade add-trailing-comma to 0.4.0
2017-07-15 12:32:36 -07:00
Anthony Sottile
0c70fa4229
Use asottile/add-trailing-comma
2017-07-12 18:30:51 -07:00
Anthony Sottile
a68c1ab0d2
Add 'types' to the schema
2017-07-02 13:20:39 -07:00