Add repo: self support for consuming own hooks #1601
Draft
shaanmajid wants to merge 4 commits intomasterfrom
Draft
Add repo: self support for consuming own hooks #1601shaanmajid wants to merge 4 commits intomasterfrom
repo: self support for consuming own hooks #1601shaanmajid wants to merge 4 commits intomasterfrom
Conversation
Allow projects that publish hooks via `.pre-commit-hooks.yaml` to consume their own hooks with `repo: self`, avoiding redundant `repo: local` definitions. Add a 5th repo type `SelfRepo` using `"self"` as the sentinel value. Hooks use `RemoteHook` shape (only `id` required, rest optional overrides). At init time, reads `.pre-commit-hooks.yaml` from the project root (no cloning) and resolves hooks using the existing manifest-lookup + override pattern. Exposes the project root as `repo_path()` for language installers. Handles `repo: self` across all code paths: config parsing, runtime hook resolution, workspace init, JSON schema, auto-update (skip), cache GC (track hook envs), tab completion, meta hooks validation, and language runner dispatch.
Test system hook execution with file filtering, config overrides (name, args), missing manifest error, unknown hook ID error, and cache GC retention of self-repo hook environments.
Add `repo: self` section to configuration.md with TOML and YAML examples. Update the prek-specific extensions list in diff.md.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1601 +/- ##
==========================================
- Coverage 91.67% 91.65% -0.02%
==========================================
Files 93 93
Lines 18333 18482 +149
==========================================
+ Hits 16807 16940 +133
- Misses 1526 1542 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.00% (23.7 MiB → 23.7 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
The INSTA_FILTERS entry for normalizing os error messages never worked: it matched `Caused by:` (capital C) but prek uses `caused by:`. Replace the broken greedy pattern with a targeted substitution that swaps only the Windows-specific `The system cannot find the file specified.` with the Unix `No such file or directory`, leaving surrounding context intact.
a57f385 to
52e586c
Compare
repo: self support for consuming own hooks repo: self support for consuming own hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1598