Split config into focused modules - #2575
Conversation
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.rswith acrates/prek/src/config/module tree and re-exported the previous public(crate) surface fromconfig/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 atcrates/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.
📦 Cargo Bloat ComparisonBinary size change: +0.00% (30.3 MiB → 30.3 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
⚡️ Hyperfine BenchmarksSummary: 0 regressions, 0 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.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 |
There was a problem hiding this comment.
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
Resultalias tostd::result::Result<T, E>, the test helpers that currently returnResult<()>will stop compiling (they rely on the single-parameteranyhow::Result). Add a test-local alias so the existing test signatures keep working.
mod tests {
use super::*;
use std::io::Write as _;
Split the config module into focused hook, pattern, priority, repo, and update modules while keeping
configas the facade.