Add the --repo CLI Flag to prek run for repository-level hook selection - #2659
Add the --repo CLI Flag to prek run for repository-level hook selection#2659pygarap wants to merge 10 commits into
--repo CLI Flag to prek run for repository-level hook selection#2659Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a --repo CLI option to filter selected hooks by their configured repository, including GitHub URL/shorthand normalization, and ensures non-matching remotes are not fetched/initialized.
Changes:
- Introduce
--repoto select hooks by configured repository (supportslocal/meta/builtin, full URLs, GitHub shorthand). - Apply repository filters during workspace hook initialization and warn on unmatched
--reposelectors. - Add documentation and tests validating selection behavior and avoiding cloning unreachable remotes.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/workspace.md | Documents repository selection semantics in workspace mode and examples. |
| docs/usage.md | Adds user-facing --repo usage and explains interactions with other filters. |
| docs/reference/cli.md | Adds --repo to CLI reference output. |
| docs/internals.md | Notes that --repo filtering happens before remote dedupe/initialization. |
| docs/diff.md | Mentions --repo in prek vs pre-commit differences. |
| crates/prek/tests/workspace.rs | Adds workspace-mode tests covering repo filtering across nested projects. |
| crates/prek/tests/run.rs | Adds run-mode tests for special repos, filter composition, and unmatched warnings; updates completion snapshot. |
| crates/prek/src/workspace.rs | Plumbs repo filters into workspace hook init planning and filters repos early. |
| crates/prek/src/cli/run/selector.rs | Implements RepoFilter with GitHub URL/shorthand canonicalization + unit tests. |
| crates/prek/src/cli/run/run.rs | Parses --repo, passes filters into init, and reports unused repo selectors. |
| crates/prek/src/cli/run/mod.rs | Re-exports RepoFilter. |
| crates/prek/src/cli/mod.rs | Defines the --repo argument and help text. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c38b6936f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
📦 Cargo Bloat Comparison
Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
⚡️ Hyperfine BenchmarksSummary: 7 regressions, 4 improvements above the 10% threshold. Environment
CLI CommandsBenchmarking basic commands in the main repo:
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base --version |
1.6 ± 0.1 | 1.4 | 2.0 | 1.00 |
prek-head --version |
1.6 ± 0.0 | 1.5 | 1.7 | 1.01 ± 0.06 |
prek list
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base list |
10.7 ± 39.4 | 5.9 | 397.3 | 1.77 ± 6.51 |
prek-head list |
6.1 ± 0.1 | 5.8 | 6.6 | 1.00 |
✅ Performance improvement for prek list: 43.5400% faster
prek validate-config .pre-commit-config.yaml
⏭️ Skipped: .pre-commit-config.yaml not found
prek sample-config
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base sample-config |
4.0 ± 10.0 | 1.8 | 60.1 | 1.17 ± 3.69 |
prek-head sample-config |
3.4 ± 6.3 | 1.7 | 39.5 | 1.00 |
✅ Performance improvement for prek sample-config: 14.6000% faster
Cold vs Warm Runs
Comparing first run (cold) vs subsequent runs (warm cache):
prek run --all-files (cold - no cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
23.8 ± 1.4 | 21.1 | 25.9 | 1.00 |
prek-head run --all-files |
24.4 ± 1.5 | 20.9 | 26.0 | 1.03 ± 0.09 |
prek run --all-files (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
24.2 ± 1.4 | 21.5 | 26.8 | 1.04 ± 0.08 |
prek-head run --all-files |
23.4 ± 1.3 | 21.3 | 25.9 | 1.00 |
Full Hook Suite
Running the builtin hook suite on the benchmark workspace:
prek run --all-files (full builtin hook suite)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
25.0 ± 15.2 | 20.7 | 129.9 | 1.00 |
prek-head run --all-files |
29.1 ± 38.7 | 21.3 | 296.8 | 1.16 ± 1.70 |
prek run --all-files (full builtin hook suite): 16.1400% slower
Individual Hook Performance
Benchmarking each hook individually on the test repo:
prek run trailing-whitespace --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run trailing-whitespace --all-files |
7.8 ± 0.4 | 7.0 | 8.7 | 1.02 ± 0.07 |
prek-head run trailing-whitespace --all-files |
7.6 ± 0.3 | 7.0 | 8.2 | 1.00 |
prek run end-of-file-fixer --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run end-of-file-fixer --all-files |
6.8 ± 0.3 | 6.3 | 7.5 | 1.00 |
prek-head run end-of-file-fixer --all-files |
15.8 ± 34.8 | 6.4 | 174.6 | 2.32 ± 5.12 |
prek run end-of-file-fixer --all-files: 132.2400% slower
prek run check-json --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-json --all-files |
6.2 ± 6.5 | 4.7 | 40.7 | 1.05 ± 1.46 |
prek-head run check-json --all-files |
5.9 ± 5.4 | 4.7 | 34.6 | 1.00 |
prek run check-yaml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-yaml --all-files |
5.1 ± 0.3 | 4.7 | 6.3 | 1.00 |
prek-head run check-yaml --all-files |
5.2 ± 0.7 | 4.7 | 7.1 | 1.02 ± 0.15 |
prek run check-toml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-toml --all-files |
5.0 ± 0.3 | 4.6 | 6.0 | 1.02 ± 0.07 |
prek-head run check-toml --all-files |
4.9 ± 0.2 | 4.5 | 5.5 | 1.00 |
prek run check-xml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-xml --all-files |
4.9 ± 0.5 | 4.5 | 7.1 | 1.00 |
prek-head run check-xml --all-files |
5.3 ± 2.7 | 4.6 | 19.5 | 1.10 ± 0.56 |
prek run check-xml --all-files: 10.0500% slower
prek run detect-private-key --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run detect-private-key --all-files |
9.6 ± 7.7 | 6.3 | 38.2 | 1.37 ± 1.11 |
prek-head run detect-private-key --all-files |
7.0 ± 0.7 | 6.4 | 10.0 | 1.00 |
✅ Performance improvement for prek run detect-private-key --all-files: 26.9800% faster
prek run fix-byte-order-marker --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run fix-byte-order-marker --all-files |
11.2 ± 8.7 | 8.1 | 53.2 | 1.10 ± 0.95 |
prek-head run fix-byte-order-marker --all-files |
10.1 ± 3.6 | 8.7 | 29.3 | 1.00 |
Installation Performance
Benchmarking hook installation (fast path hooks skip Python setup):
prek install-hooks (cold - no cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base install-hooks |
3.1 ± 0.1 | 3.0 | 3.2 | 1.00 |
prek-head install-hooks |
3.1 ± 0.1 | 3.0 | 3.2 | 1.00 ± 0.04 |
prek install-hooks (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base install-hooks |
3.0 ± 0.1 | 2.9 | 3.1 | 1.00 |
prek-head install-hooks |
6.4 ± 7.3 | 3.1 | 19.5 | 2.15 ± 2.46 |
prek install-hooks (warm - with cache): 114.5000% slower
File Filtering/Scoping Performance
Testing different file selection modes:
prek run (staged files only)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run |
14.8 ± 2.1 | 14.0 | 23.6 | 1.05 ± 0.15 |
prek-head run |
14.2 ± 0.3 | 13.7 | 14.7 | 1.00 |
prek run --files '*.json' (specific file type)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --files '*.json' |
4.9 ± 6.1 | 3.4 | 30.9 | 1.00 |
prek-head run --files '*.json' |
5.6 ± 9.3 | 3.3 | 45.1 | 1.15 ± 2.40 |
prek run --files '*.json' (specific file type): 15.0300% slower
Workspace Discovery & Initialization
Benchmarking hook discovery and initialization overhead:
prek run --dry-run --all-files (measures init overhead)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --dry-run --all-files |
6.3 ± 6.5 | 4.3 | 32.4 | 1.00 |
prek-head run --dry-run --all-files |
6.8 ± 10.6 | 4.3 | 51.7 | 1.09 ± 2.04 |
Meta Hooks Performance
Benchmarking meta hooks separately:
prek run check-hooks-apply --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-hooks-apply --all-files |
5.2 ± 0.1 | 5.0 | 5.4 | 1.00 |
prek-head run check-hooks-apply --all-files |
17.1 ± 42.4 | 5.3 | 170.1 | 3.27 ± 8.08 |
prek run check-hooks-apply --all-files: 226.5700% slower
prek run check-useless-excludes --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-useless-excludes --all-files |
7.0 ± 6.4 | 5.1 | 30.2 | 1.00 |
prek-head run check-useless-excludes --all-files |
21.9 ± 44.0 | 5.2 | 146.1 | 3.11 ± 6.86 |
prek run check-useless-excludes --all-files: 210.5300% slower
prek run identity --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run identity --all-files |
15.9 ± 39.7 | 4.4 | 158.5 | 1.39 ± 4.75 |
prek-head run identity --all-files |
11.4 ± 26.6 | 4.5 | 107.6 | 1.00 |
✅ Performance improvement for prek run identity --all-files: 28.0700% faster
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is scoped, composes cleanly with existing selection filters, and is backed by targeted unit and snapshot tests plus thorough docs.
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
@codex review |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2659 +/- ##
==========================================
+ Coverage 94.06% 94.09% +0.02%
==========================================
Files 141 141
Lines 29831 29994 +163
==========================================
+ Hits 28060 28222 +162
- Misses 1771 1772 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the documented semantics, filters remotes before initialization as intended, and includes targeted test coverage for matching, composition, and warning behavior.
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 633b5aa0d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the documented behavior, applies filtering early to avoid unnecessary cloning, and includes targeted unit/snapshot test coverage for key cases.
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
@j178 When you have a chance to review this PR, please let me know if there is anything you would like me to change to help move it forward. Thanks 🙏 |
|
Thanks. I’d prefer to wait until we get a bit more feedback or support in #2513 before moving forward with the implementation. |
|
@j178 Of course, that makes sense, thank you for clarifying. Would you consider adding a label for feature requests, either in Issues or Discussions, that are ready for contributors to pick up and implement in a PR? Thanks 🙏 |
|
See #2542:
|
Important
This PR resolves #2513
Adds a repeatable
--repo <REPO>option toprek runfor selecting hooks by their configured repository.Supported usage: