Skip cloning fully filtered remote repos#2151
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2151 +/- ##
==========================================
+ Coverage 92.50% 92.52% +0.02%
==========================================
Files 122 122
Lines 25978 26182 +204
==========================================
+ Hits 24032 24226 +194
- Misses 1946 1956 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: -0.75% (26.5 MiB → 26.3 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
⚡️ Hyperfine BenchmarksSummary: 1 regressions, 2 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 |
2.5 ± 0.1 | 2.4 | 2.9 | 1.09 ± 0.05 |
prek-head --version |
2.3 ± 0.1 | 2.2 | 2.7 | 1.00 |
prek list
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base list |
9.7 ± 0.4 | 9.3 | 11.0 | 1.02 ± 0.06 |
prek-head list |
9.5 ± 0.4 | 9.0 | 11.5 | 1.00 |
prek validate-config .pre-commit-config.yaml
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base validate-config .pre-commit-config.yaml |
3.6 ± 0.2 | 3.3 | 4.0 | 1.12 ± 0.06 |
prek-head validate-config .pre-commit-config.yaml |
3.2 ± 0.1 | 3.1 | 3.3 | 1.00 |
✅ Performance improvement for prek validate-config .pre-commit-config.yaml: 10.5500% faster
prek sample-config
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base sample-config |
2.9 ± 0.1 | 2.7 | 3.0 | 1.06 ± 0.05 |
prek-head sample-config |
2.7 ± 0.1 | 2.6 | 3.0 | 1.00 |
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 |
81.5 ± 3.1 | 78.0 | 88.7 | 1.00 |
prek-head run --all-files |
83.3 ± 4.4 | 78.9 | 90.1 | 1.02 ± 0.07 |
prek run --all-files (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
85.6 ± 3.3 | 80.1 | 92.0 | 1.03 ± 0.06 |
prek-head run --all-files |
83.5 ± 4.0 | 79.0 | 92.5 | 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 |
84.8 ± 3.6 | 78.5 | 92.9 | 1.00 ± 0.06 |
prek-head run --all-files |
84.5 ± 3.6 | 77.9 | 91.6 | 1.00 |
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 |
23.7 ± 0.8 | 22.3 | 25.1 | 1.00 |
prek-head run trailing-whitespace --all-files |
23.8 ± 0.8 | 22.2 | 25.4 | 1.00 ± 0.05 |
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 |
29.5 ± 2.2 | 26.3 | 35.0 | 1.03 ± 0.10 |
prek-head run end-of-file-fixer --all-files |
28.6 ± 1.8 | 26.1 | 33.1 | 1.00 |
prek run check-json --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-json --all-files |
10.1 ± 0.9 | 8.6 | 12.2 | 1.03 ± 0.12 |
prek-head run check-json --all-files |
9.8 ± 0.7 | 8.7 | 11.6 | 1.00 |
prek run check-yaml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-yaml --all-files |
10.2 ± 0.7 | 9.3 | 12.8 | 1.06 ± 0.09 |
prek-head run check-yaml --all-files |
9.6 ± 0.6 | 8.5 | 10.7 | 1.00 |
prek run check-toml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-toml --all-files |
10.3 ± 0.7 | 9.0 | 12.3 | 1.05 ± 0.10 |
prek-head run check-toml --all-files |
9.8 ± 0.7 | 8.7 | 11.3 | 1.00 |
prek run check-xml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-xml --all-files |
10.1 ± 0.6 | 9.4 | 12.2 | 1.06 ± 0.08 |
prek-head run check-xml --all-files |
9.5 ± 0.4 | 8.7 | 10.4 | 1.00 |
prek run detect-private-key --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run detect-private-key --all-files |
16.2 ± 1.3 | 13.9 | 18.4 | 1.05 ± 0.14 |
prek-head run detect-private-key --all-files |
15.5 ± 1.6 | 13.3 | 20.6 | 1.00 |
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 |
25.6 ± 1.8 | 22.0 | 28.2 | 1.00 |
prek-head run fix-byte-order-marker --all-files |
25.7 ± 3.2 | 21.8 | 37.5 | 1.00 ± 0.14 |
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 |
5.8 ± 0.3 | 5.5 | 6.1 | 1.00 |
prek-head install-hooks |
67.9 ± 89.3 | 5.7 | 224.2 | 11.62 ± 15.30 |
prek install-hooks (cold - no cache): 1061.6900% slower
prek install-hooks (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base install-hooks |
30.2 ± 56.1 | 5.0 | 130.5 | 5.09 ± 9.45 |
prek-head install-hooks |
5.9 ± 0.5 | 5.5 | 6.7 | 1.00 |
✅ Performance improvement for prek install-hooks (warm - with cache): 80.3700% faster
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 |
46.5 ± 1.4 | 44.1 | 49.2 | 1.02 ± 0.05 |
prek-head run |
45.4 ± 1.5 | 43.4 | 48.6 | 1.00 |
prek run --files '*.json' (specific file type)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --files '*.json' |
9.6 ± 0.6 | 8.9 | 10.7 | 1.00 |
prek-head run --files '*.json' |
10.2 ± 0.5 | 9.6 | 12.1 | 1.06 ± 0.09 |
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 |
8.8 ± 0.3 | 8.4 | 9.2 | 1.00 |
prek-head run --dry-run --all-files |
9.0 ± 0.5 | 8.3 | 10.3 | 1.02 ± 0.07 |
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 |
15.6 ± 0.6 | 14.3 | 16.4 | 1.00 |
prek-head run check-hooks-apply --all-files |
15.8 ± 0.6 | 14.9 | 16.9 | 1.01 ± 0.05 |
prek run check-useless-excludes --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-useless-excludes --all-files |
14.1 ± 0.7 | 13.2 | 15.8 | 1.04 ± 0.07 |
prek-head run check-useless-excludes --all-files |
13.5 ± 0.4 | 12.8 | 14.2 | 1.00 |
prek run identity --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run identity --all-files |
13.4 ± 0.7 | 12.6 | 15.6 | 1.06 ± 0.07 |
prek-head run identity --all-files |
12.7 ± 0.3 | 12.1 | 13.2 | 1.00 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2aac42fb67
ℹ️ 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".
| if !remote_keys_to_init.contains(&repo.key()) { | ||
| repos.push(None); | ||
| continue; |
There was a problem hiding this comment.
Skip filtered duplicate repo entries independently
When two configured remote entries share the same repo/rev, this global remote_keys_to_init check treats every entry with that key as kept once any one of them survives the filters. In a workspace where one project (or a second entry in the same config) selects a valid hook from that remote while another same-key entry is fully excluded by --skip/--group, the excluded entry still gets initialized in internal_init_hooks before final filtering; that can surface HookNotFound for a skipped hook and defeats the new “fully filtered repos are not initialized” behavior. Track whether each configured repo entry is kept separately from the deduplicated clone key.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR improves prek’s hook initialization so remote repositories are not cloned when all of their configured hooks are filtered out (e.g., via --skip or --group), enabling offline/CI usage as requested in #2149.
Changes:
- Add pre-clone filtering (
HookInitFilters) toWorkspace/Projectrepo initialization to skip cloning fully filtered remote repos. - Introduce a lightweight “configured hook” matcher to apply skip/group logic using config-only data (before cloning).
- Add integration tests to verify skipped/group-excluded remotes are not cloned, while unmatched
--skipstill clones (and fails for nonexistent remotes).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/prek/tests/run.rs | Adds regression tests covering skip/group behavior around remote cloning. |
| crates/prek/src/workspace.rs | Implements HookInitFilters and stores Option<Repo> per configured repo to represent skipped remotes. |
| crates/prek/src/cli/run/selector.rs | Adds ConfiguredHook plus matching helpers for skip/group evaluation pre-clone. |
| crates/prek/src/cli/run/run.rs | Passes run-time selectors + group filters into workspace hook initialization. |
| crates/prek/src/cli/run/mod.rs | Re-exports ConfiguredHook for internal use. |
| crates/prek/src/cli/list.rs | Passes selector-aware hook-init filters to avoid cloning remotes skipped by --skip. |
| crates/prek/src/cli/install.rs | Same as list: avoids cloning remotes that are fully ruled out by skip selectors. |
| crates/prek/src/hooks/meta_hooks.rs | Updates Project::init_hooks callsite with a “no filtering” init mode. |
Closes #2149