Skip to content

Skip cloning fully filtered remote repos#2151

Open
j178 wants to merge 1 commit into
masterfrom
skip-clone
Open

Skip cloning fully filtered remote repos#2151
j178 wants to merge 1 commit into
masterfrom
skip-clone

Conversation

@j178
Copy link
Copy Markdown
Owner

@j178 j178 commented Jun 4, 2026

Closes #2149

@j178 j178 added the enhancement New feature or request label Jun 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

❌ Patch coverage is 93.64407% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.52%. Comparing base (aca63ee) to head (2aac42f).

Files with missing lines Patch % Lines
crates/prek/src/workspace.rs 88.88% 9 Missing ⚠️
crates/prek/src/cli/run/selector.rs 95.68% 6 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot Bot commented Jun 4, 2026

📦 Cargo Bloat Comparison

Binary size change: -0.75% (26.5 MiB → 26.3 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size             Crate Name
 1.2%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_41_0_aes_gcm_encrypt_avx512
 1.2%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_41_0_aes_gcm_decrypt_avx512
 0.3%   0.7%  90.0KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  89.0KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.5%  69.8KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  62.0KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.4%  49.4KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4%  48.2KiB              prek prek::run::{{closure}}
 0.2%   0.3%  44.5KiB              prek prek::cli::run::run::run::{{closure}}
 0.1%   0.2%  31.1KiB             prek? <prek::cli::RunOptions as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  30.6KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2%  29.6KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  28.1KiB      serde_saphyr granit_parser::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_41_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_41_0_edwards25519_scalarmuldouble
 0.1%   0.2%  26.1KiB              prek prek::cli::try_repo::try_repo::{{closure}}
 0.1%   0.2%  23.0KiB      serde_saphyr granit_parser::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  22.3KiB         [Unknown] Lp384_montjscalarmul_alt_p384_montjadd
 0.1%   0.2%  21.9KiB     serde_saphyr? <serde_saphyr::de::YamlDeserializer as serde_core::de::Deserializer>::deserialize_map
 0.1%   0.2%  21.5KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
41.7%  86.3%  11.0MiB                   And 24066 smaller methods. Use -n N to show more.
48.3% 100.0%  12.7MiB                   .text section size, the file size is 26.3MiB

Base Branch Results

 File  .text     Size             Crate Name
 1.2%   2.5% 332.0KiB        aws_lc_sys aws_lc_0_41_0_aes_gcm_encrypt_avx512
 1.2%   2.5% 332.0KiB        aws_lc_sys aws_lc_0_41_0_aes_gcm_decrypt_avx512
 0.3%   0.7%  90.0KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  81.9KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.5%  69.8KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  62.6KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.4%  49.4KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4%  48.3KiB              prek prek::run::{{closure}}
 0.2%   0.3%  44.0KiB              prek prek::cli::run::run::run::{{closure}}
 0.1%   0.2%  31.4KiB             prek? <prek::cli::RunOptions as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  30.6KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2%  29.6KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  28.1KiB      serde_saphyr granit_parser::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_41_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_41_0_edwards25519_scalarmuldouble
 0.1%   0.2%  26.1KiB              prek prek::cli::try_repo::try_repo::{{closure}}
 0.1%   0.2%  24.4KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2%  23.0KiB      serde_saphyr granit_parser::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  22.3KiB         [Unknown] Lp384_montjscalarmul_alt_p384_montjadd
 0.1%   0.2%  21.8KiB     serde_saphyr? <serde_saphyr::de::YamlDeserializer as serde_core::de::Deserializer>::deserialize_map
42.0%  86.5%  11.1MiB                   And 24142 smaller methods. Use -n N to show more.
48.6% 100.0%  12.9MiB                   .text section size, the file size is 26.5MiB

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot Bot commented Jun 4, 2026

⚡️ Hyperfine Benchmarks

Summary: 1 regressions, 2 improvements above the 10% threshold.

Environment
  • OS: Linux 6.17.0-1015-azure
  • CPU: 4 cores
  • prek version: prek 0.4.4+3 (70cb336 2026-06-04)
  • Rust version: rustc 1.96.0 (ac68faa20 2026-05-25)
  • Hyperfine version: hyperfine 1.20.0
CLI Commands

Benchmarking basic commands in the main repo:

prek --version

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

⚠️ Warning: Performance regression for 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

@j178 j178 marked this pull request as ready for review June 4, 2026 13:18
Copilot AI review requested due to automatic review settings June 4, 2026 13:18
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +1014 to +1016
if !remote_keys_to_init.contains(&repo.key()) {
repos.push(None);
continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) to Workspace/Project repo 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 --skip still 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make possible to not clone skipped repos with prek run

2 participants