Add glob list support for file patterns (files and exclude)#1197
Add glob list support for file patterns (files and exclude)#1197j178 merged 10 commits intoj178:masterfrom
files and exclude)#1197Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1197 +/- ##
==========================================
+ Coverage 90.25% 90.29% +0.03%
==========================================
Files 81 81
Lines 15952 16116 +164
==========================================
+ Hits 14398 14552 +154
- Misses 1554 1564 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.90% (22.3 MiB → 22.5 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
|
@j178 - hi. Can you enable running github actions for users who are not new to github? its an optional setting. It will make contributing here much simpler. |
|
Thanks for contributing — this looks good! But since this is a new feature, I’ll need a bit more time to think through the interface design and the overall user experience. Also, dependencies are normally updated by the Renovate bot, so we usually don’t include them in feature PRs. It doesn’t look like they’re needed for this one, right? |
yup not needed. I just ran cargo update, will undo and rebase. |
|
@j178 - rebased on main and removed the Cargo.toml/lock version updates. Lemme know if you need me to rebase again in the future. |
# Conflicts: # docs/configuration.md
files and exclude)
There was a problem hiding this comment.
Pull request overview
This PR adds support for glob patterns as an alternative to regex patterns for the files and exclude fields in prek configuration. The change maintains full backward compatibility with existing regex-based configurations.
Changes:
- Introduced
FilePatternenum supporting both regex (default) and glob patterns (single or list) - Updated all file/exclude pattern references throughout the codebase to use the new type
- Added comprehensive test coverage for glob pattern matching and edge cases
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/prek/src/config.rs | Core implementation of FilePattern enum with deserialization, matching, and display logic |
| crates/prek/src/hook.rs | Updated Hook struct to use FilePattern instead of SerdeRegex |
| crates/prek/src/cli/run/filter.rs | Updated FilenameFilter to work with FilePattern type |
| crates/prek/src/hooks/meta_hooks.rs | Updated meta hooks to use FilePattern and improved error messages |
| prek.schema.json | JSON schema definition for the new FilePattern type supporting regex and glob variants |
| docs/configuration.md | Documentation explaining glob pattern usage with examples |
| crates/prek/tests/run.rs | Integration test demonstrating glob patterns with multiple hooks |
| crates/prek/tests/meta_hooks.rs | Updated snapshot tests reflecting new error message format |
| crates/prek/src/snapshots/*.snap | Updated snapshots showing Regex() wrapper and improved formatting |
| Cargo.toml | Added globset dependency |
| crates/prek/src/cli/auto_update.rs | Added GPG signing disablement for test commits (unrelated fix) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you, let's merge! |
This PR adds support for glob patterns:
Why? The new monorepo support
prekoffers is nice, but its limited. In glob patterns enhance this further making prek much more versatile - globs are one of the key features of lefthook, that are missing. Furthermore, thepatternusage from pre-commit is inefficient and not very nice to work with - in my humble opinion, so this PR offers a completely backwards compatible alternative. Default is what it always was, while you can opt in to glob patterns.