Match files/exclude filter against relative path of nested project#1624
Merged
j178 merged 3 commits intoj178:masterfrom Feb 12, 2026
Merged
Match files/exclude filter against relative path of nested project#1624j178 merged 3 commits intoj178:masterfrom
files/exclude filter against relative path of nested project#1624j178 merged 3 commits intoj178:masterfrom
Conversation
Signed-off-by: Tin Lai <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1624 +/- ##
==========================================
+ Coverage 91.73% 91.80% +0.06%
==========================================
Files 96 96
Lines 18630 18941 +311
==========================================
+ Hits 17091 17389 +298
- Misses 1539 1552 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts how prek applies per-project include/exclude patterns in a workspace so that nested projects evaluate patterns against paths relative to their own project root (not the workspace root), matching expected monorepo behavior.
Changes:
- Strip the project’s
relative_pathprefix before applying project-levelfiles/excludefilters. - Add an integration snapshot test asserting nested-project excludes are evaluated against project-relative paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/prek/src/cli/run/filter.rs | Updates project-level filename filtering to apply patterns to paths relative to each project root. |
| crates/prek/tests/workspace.rs | Adds a regression test validating nested workspace exclude behavior is project-relative. |
📦 Cargo Bloat ComparisonBinary size change: +0.00% (23.8 MiB → 23.8 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
files/exclude filter against relative path of nested workspace
files/exclude filter against relative path of nested workspacefiles/exclude filter against relative path of nested project
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.
Previously, in a setup that looks like
mynestedrepois a nested folder using the workspace feature with a nested.pre-commit-config.yaml. Ideally (especially in a monorepo setup), it shouldn't need to care about any folder level above it.Previously, if
mynestedrepo/.pre-commit-config.yamlB containsone would expect
mynestedrepo/tobeexcludedto be excluded. However, the path passed from the filename filter previously uses the full path, so it will still modify thenodonttrackthis.mdfile even though it should be excluded.Currently, the inner settings exclude pattern needs to specify either
(^mynestedrepo/tobeexcluded/)(which is not ideal if we want the inner repo to be agnoistic to any folder above it) or(tobeexcluded/)(which risk excluding some wanted folder if the exclude pattern is generic).This PR makes it so that only the inner relative path is passed to the filename filter.
i.e., instead of passing
mynestedrepo/tobeexcluded/nodonttrackthis.mdwe pass
tobeexcluded/nodonttrackthis.mdto the inner project instead