Skip to content

Refactor config layout#1407

Merged
j178 merged 4 commits intomasterfrom
config-layout
Jan 19, 2026
Merged

Refactor config layout#1407
j178 merged 4 commits intomasterfrom
config-layout

Conversation

@j178
Copy link
Owner

@j178 j178 commented Jan 19, 2026

No description provided.

@j178 j178 added the internal Internal changes label Jan 19, 2026
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 94.48441% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.42%. Comparing base (e9716ae) to head (092a36e).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
crates/prek/src/config.rs 89.65% 15 Missing ⚠️
crates/prek/src/hook.rs 98.55% 3 Missing ⚠️
crates/prek/src/cli/completion.rs 0.00% 2 Missing ⚠️
crates/prek/src/hooks/builtin_hooks/mod.rs 93.93% 2 Missing ⚠️
crates/prek/src/hooks/meta_hooks.rs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1407      +/-   ##
==========================================
+ Coverage   90.39%   90.42%   +0.02%     
==========================================
  Files          82       82              
  Lines       16262    16447     +185     
==========================================
+ Hits        14700    14872     +172     
- Misses       1562     1575      +13     

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions
Copy link

github-actions bot commented Jan 19, 2026

📦 Cargo Bloat Comparison

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

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 71.4KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.7% 62.6KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.6% 55.3KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 46.3KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.7KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.5% 42.7KiB         prek prek::identify::by_extension::{{closure}}
 0.2%   0.4% 35.1KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 31.8KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 30.0KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.2% 21.5KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.3KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.3KiB         prek prek::hooks::meta_hooks::check_hooks_apply::{{closure}}
 0.1%   0.2% 18.3KiB         prek prek::hooks::meta_hooks::check_hooks_apply::{{closure}}
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.6%  91.6%  8.2MiB              And 19832 smaller methods. Use -n N to show more.
40.0% 100.0%  9.0MiB              .text section size, the file size is 22.5MiB

Base Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 71.7KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.6% 54.6KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 49.8KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 46.3KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.7KiB         prek prek::identify::by_extension::{{closure}}
 0.2%   0.5% 42.6KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 35.1KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 32.0KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 30.0KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.2% 21.5KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 21.0KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.8KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.3KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.7%  91.6%  8.2MiB              And 19817 smaller methods. Use -n N to show more.
40.0% 100.0%  9.0MiB              .text section size, the file size is 22.5MiB

Copy link
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 refactors the configuration type hierarchy to better represent where hook fields like priority can be specified. The main goal is to enforce that priority can only be set in project config files (.pre-commit-config.yaml) and not in hook manifests (.pre-commit-hooks.yaml).

Changes:

  • Introduced a new HookSpec type as a unified internal representation for all hook types
  • Moved priority field from HookOptions to individual config-level hook types (RemoteHook, LocalHook, MetaHook, BuiltinHook)
  • Refactored LocalHook, MetaHook, and BuiltinHook from tuple structs wrapping ManifestHook to proper structs with their own fields

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
prek.schema.json Updated JSON schema: renamed ManifestHook to LocalHook in schema, moved definition order, and added documentation clarifying that priority is only allowed in project config files
crates/prek/src/config.rs Core refactoring: introduced HookSpec type, moved priority from HookOptions to config-specific hook types, restructured LocalHook/MetaHook/BuiltinHook as proper structs, added From implementations, removed unused instrument import
crates/prek/src/workspace.rs Updated to use HookSpec instead of ManifestHook, renamed variables for clarity, added conversions to HookSpec
crates/prek/src/hook.rs Changed Repo enum to use HookSpec, updated HookBuilder to work with HookSpec, modified priority access to read from hook_spec.priority
crates/prek/src/hooks/meta_hooks.rs Removed tuple struct wrapper access (.0), updated to construct MetaHook directly, removed unused import
crates/prek/src/hooks/builtin_hooks/mod.rs Removed tuple struct wrapper access, updated to construct BuiltinHook directly with all required fields, removed unused Language import
crates/prek/src/cli/completion.rs Updated field access to remove tuple struct wrapper (.0)
crates/prek/src/snapshots/* Updated snapshots to reflect structural changes: priority moved out of HookOptions, LocalHook/MetaHook/BuiltinHook shown as proper structs

@j178 j178 merged commit 63a9c5c into master Jan 19, 2026
22 checks passed
@j178 j178 deleted the config-layout branch January 19, 2026 09:54
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.

1 participant