Skip to content

Split config into focused modules - #2575

Merged
j178 merged 1 commit into
masterfrom
split-config
Aug 17, 2026
Merged

Split config into focused modules#2575
j178 merged 1 commit into
masterfrom
split-config

Conversation

@j178

@j178 j178 commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Split the config module into focused hook, pattern, priority, repo, and update modules while keeping config as the facade.

Copilot AI lite review requested due to automatic review settings August 17, 2026 10:13
@j178 j178 added the internal Internal changes label Aug 17, 2026 — with ChatGPT Codex Connector
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.23206% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.77%. Comparing base (8144d69) to head (715a454).

Files with missing lines Patch % Lines
crates/prek/src/config/repo.rs 80.41% 28 Missing ⚠️
crates/prek/src/config/hook.rs 92.21% 19 Missing ⚠️
crates/prek/src/config/pattern.rs 96.98% 6 Missing ⚠️
crates/prek/src/config/mod.rs 99.49% 5 Missing ⚠️
crates/prek/src/config/priority.rs 92.75% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2575      +/-   ##
==========================================
- Coverage   93.78%   93.77%   -0.01%     
==========================================
  Files         135      140       +5     
  Lines       29049    29051       +2     
==========================================
+ Hits        27243    27244       +1     
- Misses       1806     1807       +1     

☔ 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Splits the former monolithic crates/prek/src/config.rs into focused submodules (hook, pattern, priority, repo, update) with config/mod.rs acting as the facade, and updates existing insta snapshots to reflect the new module source paths.

Changes:

  • Replaced crates/prek/src/config.rs with a crates/prek/src/config/ module tree and re-exported the previous public(crate) surface from config/mod.rs.
  • Moved hook/repo/pattern/priority/update parsing logic into dedicated files to improve code locality and maintainability.
  • Updated config-related snapshot metadata (source:) to point at crates/prek/src/config/mod.rs.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/prek/src/config/mod.rs New config facade module that defines Config/Error APIs and re-exports types from submodules.
crates/prek/src/config/hook.rs Hook-related types (languages, stages, options) extracted into a dedicated module.
crates/prek/src/config/pattern.rs File pattern parsing/matching (regex/glob) extracted into a dedicated module, including tests.
crates/prek/src/config/priority.rs Priority aliasing and group-name validation extracted into a dedicated module.
crates/prek/src/config/repo.rs Repo model and custom repo deserialization extracted into a dedicated module.
crates/prek/src/config/update.rs prek update options and StringOrList glob parsing extracted into a dedicated module.
crates/prek/src/config.rs Removed former monolithic config implementation (now replaced by config/ module tree).
crates/prek/src/config/snapshots/prek__config__tests__read_yaml_config.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__read_toml_config.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__read_manifest.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__read_config_with_nested_merge_keys.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__read_config_with_merge_keys.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__parse_repos.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__parse_repos-6.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__parse_repos-4.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__parse_repos-3.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__parse_hooks-3.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__numeric_rev_is_parsed_as_string.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__meta_hooks-5.snap Snapshot metadata updated to reflect new source module path.
crates/prek/src/config/snapshots/prek__config__tests__language_version.snap Snapshot metadata updated to reflect new source module path.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@prek-ci-bot

prek-ci-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

📦 Cargo Bloat Comparison

Binary size change: +0.00% (30.3 MiB → 30.3 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size             Crate Name
 1.1%   2.2% 332.0KiB        aws_lc_sys aws_lc_0_44_0_aes_gcm_encrypt_avx512
 1.1%   2.2% 332.0KiB        aws_lc_sys aws_lc_0_44_0_aes_gcm_decrypt_avx512
 0.2%   0.5%  72.2KiB              prek <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.4%  57.8KiB              prek prek::run::{closure#0}
 0.2%   0.4%  53.5KiB              prek <<prek::config::hook::HookWire as serde_core::de::Deserialize>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::<<serde_saphyr::de::deserializer::YamlDeserializer as serde_core::de::Deserializer>::deserialize_map::MA>
 0.2%   0.3%  49.4KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.3%  48.3KiB              prek <<prek::config::Config as serde_core::de::Deserialize>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::<<serde_saphyr::de::deserializer::YamlDeserializer as serde_core::de::Deserializer>::deserialize_map::MA>
 0.1%   0.3%  46.2KiB              prek <prek::languages::ruby::installer::RubyInstaller>::install::{closure#0}
 0.1%   0.3%  41.3KiB              prek prek::cli::run::run::run::{closure#0}
 0.1%   0.3%  37.7KiB              prek <prek::languages::node::installer::NodeInstaller>::install::{closure#0}
 0.1%   0.2%  34.3KiB              prek <prek::cli::RunOptions as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  33.2KiB              prek <prek::languages::golang::installer::GoInstaller>::install::{closure#0}
 0.1%   0.2%  31.3KiB              prek <prek::languages::bun::installer::BunInstaller>::install::{closure#0}
 0.1%   0.2%  29.4KiB     granit_parser <granit_parser::scanner::Scanner<granit_parser::input::str::StrInput>>::fetch_more_tokens
 0.1%   0.2%  29.1KiB              prek <prek::languages::deno::installer::DenoInstaller>::download::{closure#0}
 0.1%   0.2%  28.8KiB     granit_parser <granit_parser::scanner::Scanner<granit_parser::input::str::StrInput>>::fetch_more_tokens
 0.1%   0.2%  28.6KiB    cargo_metadata <&mut serde_json::de::Deserializer<serde_json::read::StrRead> as serde_core::de::Deserializer>::deserialize_struct::<<cargo_metadata::Package as serde_core::de::Deserialize>::deserialize::__Visitor>
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_44_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_44_0_edwards25519_scalarmuldouble
 0.1%   0.2%  27.0KiB              prek <prek::languages::mise::installer::MiseInstaller>::download::{closure#0}
42.6%  88.1%  12.9MiB                   And 26774 smaller methods. Use -n N to show more.
48.4% 100.0%  14.7MiB                   .text section size, the file size is 30.3MiB

Base Branch Results

 File  .text     Size             Crate Name
 1.1%   2.2% 332.0KiB        aws_lc_sys aws_lc_0_44_0_aes_gcm_encrypt_avx512
 1.1%   2.2% 332.0KiB        aws_lc_sys aws_lc_0_44_0_aes_gcm_decrypt_avx512
 0.2%   0.5%  71.8KiB              prek <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.4%  65.4KiB              prek prek::run::{closure#0}
 0.2%   0.4%  53.5KiB              prek <<prek::config::HookWire as serde_core::de::Deserialize>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::<<serde_saphyr::de::deserializer::YamlDeserializer as serde_core::de::Deserializer>::deserialize_map::MA>
 0.2%   0.3%  49.4KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.3%  48.3KiB              prek <<prek::config::Config as serde_core::de::Deserialize>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::<<serde_saphyr::de::deserializer::YamlDeserializer as serde_core::de::Deserializer>::deserialize_map::MA>
 0.2%   0.3%  46.7KiB              prek <prek::languages::ruby::installer::RubyInstaller>::install::{closure#0}
 0.1%   0.3%  43.0KiB              prek prek::cli::run::run::run::{closure#0}
 0.1%   0.2%  34.9KiB              prek <prek::languages::node::installer::NodeInstaller>::install::{closure#0}
 0.1%   0.2%  34.3KiB              prek <prek::cli::RunOptions as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  32.6KiB              prek <prek::languages::bun::installer::BunInstaller>::install::{closure#0}
 0.1%   0.2%  32.6KiB              prek <prek::languages::golang::installer::GoInstaller>::install::{closure#0}
 0.1%   0.2%  29.4KiB     granit_parser <granit_parser::scanner::Scanner<granit_parser::input::str::StrInput>>::fetch_more_tokens
 0.1%   0.2%  29.3KiB              prek <prek::languages::deno::installer::DenoInstaller>::download::{closure#0}
 0.1%   0.2%  28.8KiB     granit_parser <granit_parser::scanner::Scanner<granit_parser::input::str::StrInput>>::fetch_more_tokens
 0.1%   0.2%  28.6KiB    cargo_metadata <&mut serde_json::de::Deserializer<serde_json::read::StrRead> as serde_core::de::Deserializer>::deserialize_struct::<<cargo_metadata::Package as serde_core::de::Deserialize>::deserialize::__Visitor>
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_44_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_44_0_edwards25519_scalarmuldouble
 0.1%   0.2%  27.0KiB              prek <prek::languages::mise::installer::MiseInstaller>::download::{closure#0}
42.6%  88.1%  12.9MiB                   And 26756 smaller methods. Use -n N to show more.
48.4% 100.0%  14.7MiB                   .text section size, the file size is 30.3MiB

@prek-ci-bot

prek-ci-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

⚡️ Hyperfine Benchmarks

Summary: 0 regressions, 0 improvements above the 10% threshold.

Environment
  • OS: Linux 6.17.0-1022-azure
  • CPU: 4 cores
  • prek version: prek 0.4.14+6 (1a93672 2026-08-17)
  • Rust version: rustc 1.97.1 (8bab26f4f 2026-07-14)
  • 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.4 ± 0.1 2.2 2.9 1.03 ± 0.07
prek-head --version 2.3 ± 0.1 2.1 2.7 1.00

prek list

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base list 10.2 ± 0.2 9.7 10.8 1.02 ± 0.04
prek-head list 9.9 ± 0.3 9.3 10.9 1.00

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 2.7 ± 0.1 2.6 2.9 1.07 ± 0.04
prek-head sample-config 2.5 ± 0.1 2.4 2.8 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 41.6 ± 1.6 40.2 45.6 1.02 ± 0.05
prek-head run --all-files 40.9 ± 1.0 38.8 42.1 1.00

prek run --all-files (warm - with cache)

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --all-files 40.4 ± 1.2 38.0 42.4 1.00
prek-head run --all-files 41.3 ± 1.5 38.6 43.9 1.02 ± 0.05
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 41.2 ± 1.6 37.5 43.9 1.01 ± 0.05
prek-head run --all-files 40.7 ± 1.1 37.0 42.7 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 14.1 ± 0.4 13.1 15.0 1.01 ± 0.04
prek-head run trailing-whitespace --all-files 13.9 ± 0.4 13.3 14.9 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 12.2 ± 0.7 11.3 14.0 1.01 ± 0.07
prek-head run end-of-file-fixer --all-files 12.0 ± 0.5 11.0 13.0 1.00

prek run check-json --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-json --all-files 8.4 ± 0.4 7.9 9.4 1.03 ± 0.06
prek-head run check-json --all-files 8.2 ± 0.3 7.7 8.9 1.00

prek run check-yaml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-yaml --all-files 8.1 ± 0.1 7.8 8.4 1.01 ± 0.04
prek-head run check-yaml --all-files 8.0 ± 0.2 7.6 8.8 1.00

prek run check-toml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-toml --all-files 8.2 ± 0.3 7.7 9.1 1.01 ± 0.08
prek-head run check-toml --all-files 8.1 ± 0.5 7.5 10.3 1.00

prek run check-xml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-xml --all-files 8.3 ± 0.5 7.7 9.7 1.06 ± 0.07
prek-head run check-xml --all-files 7.9 ± 0.3 7.4 8.7 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 12.1 ± 0.6 11.0 13.6 1.05 ± 0.10
prek-head run detect-private-key --all-files 11.5 ± 1.0 10.3 14.0 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 14.2 ± 0.9 12.8 16.3 1.00
prek-head run fix-byte-order-marker --all-files 14.3 ± 0.9 12.9 16.3 1.01 ± 0.09
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.1 ± 0.1 5.0 5.2 1.00
prek-head install-hooks 5.2 ± 0.1 5.1 5.3 1.03 ± 0.03

prek install-hooks (warm - with cache)

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base install-hooks 5.2 ± 0.1 5.0 5.4 1.04 ± 0.06
prek-head install-hooks 5.0 ± 0.2 4.7 5.3 1.00
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 25.4 ± 0.5 24.5 26.3 1.02 ± 0.03
prek-head run 24.9 ± 0.6 24.0 26.0 1.00

prek run --files '*.json' (specific file type)

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --files '*.json' 5.6 ± 0.2 5.4 6.1 1.06 ± 0.04
prek-head run --files '*.json' 5.3 ± 0.1 5.2 5.6 1.00
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 7.3 ± 0.1 7.1 7.5 1.02 ± 0.02
prek-head run --dry-run --all-files 7.2 ± 0.1 7.0 7.5 1.00
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 8.7 ± 0.1 8.5 8.9 1.05 ± 0.02
prek-head run check-hooks-apply --all-files 8.3 ± 0.1 8.1 8.5 1.00

prek run check-useless-excludes --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-useless-excludes --all-files 8.4 ± 0.1 8.3 8.7 1.01 ± 0.02
prek-head run check-useless-excludes --all-files 8.3 ± 0.1 8.2 8.5 1.00

prek run identity --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run identity --all-files 7.7 ± 0.2 7.4 8.2 1.05 ± 0.03
prek-head run identity --all-files 7.3 ± 0.1 7.1 7.5 1.00

Copilot AI review requested due to automatic review settings August 17, 2026 10:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Suppressed comments (1)

crates/prek/src/config/mod.rs:377

  • After switching the module-level Result alias to std::result::Result<T, E>, the test helpers that currently return Result<()> will stop compiling (they rely on the single-parameter anyhow::Result). Add a test-local alias so the existing test signatures keep working.
mod tests {
    use super::*;
    use std::io::Write as _;

Comment thread crates/prek/src/config/mod.rs
Comment thread crates/prek/src/config/hook.rs
Comment thread crates/prek/src/config/pattern.rs
Comment thread crates/prek/src/config/repo.rs
Comment thread crates/prek/src/config/update.rs
@j178
j178 merged commit a31a6ed into master Aug 17, 2026
37 checks passed
@j178
j178 deleted the split-config branch August 17, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Internal changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants