Skip to content

Add project auto-update cooldown config#2044

Merged
j178 merged 3 commits intomasterfrom
auto-update-settings
May 5, 2026
Merged

Add project auto-update cooldown config#2044
j178 merged 3 commits intomasterfrom
auto-update-settings

Conversation

@j178
Copy link
Copy Markdown
Owner

@j178 j178 commented May 4, 2026

Summary

Add project-level auto_update.cooldown_days support for prek.toml and .pre-commit-config.yaml.

Closes #1765

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

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 95.23810% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.29%. Comparing base (c52833e) to head (525a0c4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
crates/prek/src/cli/auto_update/mod.rs 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2044      +/-   ##
==========================================
+ Coverage   92.26%   92.29%   +0.02%     
==========================================
  Files         119      119              
  Lines       24266    24281      +15     
==========================================
+ Hits        22389    22410      +21     
+ Misses       1877     1871       -6     

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

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot Bot commented May 4, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (26.1 MiB → 26.1 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_39_1_aes_gcm_encrypt_avx512
 1.2%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_39_1_aes_gcm_decrypt_avx512
 0.3%   0.7%  90.7KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  83.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  74.4KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.5%  65.4KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4%  53.3KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4%  48.7KiB              prek prek::run::{{closure}}
 0.2%   0.3%  42.5KiB              prek prek::cli::run::run::run::{{closure}}
 0.1%   0.3%  33.1KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  32.0KiB             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%  28.6KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_39_1_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_39_1_edwards25519_scalarmuldouble
 0.1%   0.2%  26.2KiB              prek prek::cli::try_repo::try_repo::{{closure}}
 0.1%   0.2%  23.3KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2%  22.5KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  22.3KiB         [Unknown] Lp384_montjscalarmul_alt_p384_montjadd
 0.1%   0.2%  21.5KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
41.4%  86.2%  10.8MiB                   And 23862 smaller methods. Use -n N to show more.
48.1% 100.0%  12.5MiB                   .text section size, the file size is 26.1MiB

Base Branch Results

 File  .text     Size             Crate Name
 1.2%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_39_1_aes_gcm_encrypt_avx512
 1.2%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_39_1_aes_gcm_decrypt_avx512
 0.3%   0.7%  90.7KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  83.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5%  65.4KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  61.3KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.4%  53.3KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.3%  42.1KiB              prek prek::cli::run::run::run::{{closure}}
 0.1%   0.3%  35.2KiB              prek prek::run::{{closure}}
 0.1%   0.3%  32.6KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  29.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%  28.6KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_39_1_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_39_1_edwards25519_scalarmuldouble
 0.1%   0.2%  26.2KiB              prek prek::cli::try_repo::try_repo::{{closure}}
 0.1%   0.2%  23.3KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2%  22.5KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  22.3KiB         [Unknown] Lp384_montjscalarmul_alt_p384_montjadd
 0.1%   0.2%  21.5KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
41.5%  86.4%  10.8MiB                   And 23818 smaller methods. Use -n N to show more.
48.0% 100.0%  12.5MiB                   .text section size, the file size is 26.1MiB

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot Bot commented May 4, 2026

⚡️ Hyperfine Benchmarks

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

Environment
  • OS: Linux 6.17.0-1010-azure
  • CPU: 4 cores
  • prek version: prek 0.3.11+24 (8a41804 2026-05-05)
  • Rust version: rustc 1.95.0 (59807616e 2026-04-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.6 ± 0.1 2.4 3.2 1.02 ± 0.06
prek-head --version 2.5 ± 0.1 2.4 2.7 1.00

prek list

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base list 9.9 ± 0.2 9.6 10.5 1.00
prek-head list 9.9 ± 0.2 9.5 10.4 1.00 ± 0.03

prek validate-config .pre-commit-config.yaml

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base validate-config .pre-commit-config.yaml 3.5 ± 0.1 3.3 3.7 1.01 ± 0.04
prek-head validate-config .pre-commit-config.yaml 3.5 ± 0.1 3.3 3.7 1.00

prek sample-config

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base sample-config 2.8 ± 0.2 2.7 4.0 1.00 ± 0.08
prek-head sample-config 2.8 ± 0.1 2.7 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 153.4 ± 2.4 149.4 157.0 1.01 ± 0.03
prek-head run --all-files 152.1 ± 4.3 147.3 162.1 1.00

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

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --all-files 151.6 ± 4.3 146.2 162.0 1.00
prek-head run --all-files 151.9 ± 4.6 146.0 160.7 1.00 ± 0.04
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 155.5 ± 3.9 147.0 163.0 1.00
prek-head run --all-files 155.7 ± 11.1 147.8 223.0 1.00 ± 0.08
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 22.0 ± 0.6 21.1 23.4 1.00 ± 0.03
prek-head run trailing-whitespace --all-files 22.0 ± 0.5 21.3 23.2 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 29.0 ± 2.1 25.8 33.1 1.00
prek-head run end-of-file-fixer --all-files 29.9 ± 4.5 24.7 46.7 1.03 ± 0.17

prek run check-json --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-json --all-files 13.5 ± 0.2 13.2 14.0 1.02 ± 0.04
prek-head run check-json --all-files 13.2 ± 0.5 12.2 13.9 1.00

prek run check-yaml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-yaml --all-files 12.6 ± 0.5 12.1 13.7 1.01 ± 0.04
prek-head run check-yaml --all-files 12.4 ± 0.2 12.1 12.8 1.00

prek run check-toml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-toml --all-files 12.8 ± 0.3 12.2 13.4 1.00
prek-head run check-toml --all-files 12.9 ± 0.3 12.4 13.6 1.01 ± 0.03

prek run check-xml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-xml --all-files 13.0 ± 0.6 12.1 15.8 1.01 ± 0.06
prek-head run check-xml --all-files 12.9 ± 0.4 12.2 13.6 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 19.6 ± 1.4 17.4 23.8 1.01 ± 0.10
prek-head run detect-private-key --all-files 19.4 ± 1.4 16.6 22.4 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 24.2 ± 1.8 20.6 26.8 1.02 ± 0.10
prek-head run fix-byte-order-marker --all-files 23.8 ± 1.4 21.4 26.8 1.00
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.4 ± 0.1 5.3 5.5 1.00 ± 0.03
prek-head install-hooks 5.4 ± 0.1 5.2 5.6 1.00

prek install-hooks (warm - with cache)

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base install-hooks 5.3 ± 0.1 5.3 5.5 1.01 ± 0.02
prek-head install-hooks 5.3 ± 0.1 5.3 5.4 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 52.8 ± 1.5 50.7 57.2 1.00 ± 0.04
prek-head run 52.7 ± 1.3 50.1 55.3 1.00

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

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --files '*.json' 9.2 ± 0.1 8.9 9.4 1.00
prek-head run --files '*.json' 9.3 ± 0.1 9.0 9.6 1.01 ± 0.02
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 17.4 ± 0.3 16.9 18.3 1.01 ± 0.02
prek-head run --dry-run --all-files 17.1 ± 0.2 16.7 17.7 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 14.7 ± 0.2 14.4 15.0 1.13 ± 0.02
prek-head run check-hooks-apply --all-files 13.0 ± 0.1 12.8 13.2 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 13.3 ± 0.4 13.0 14.7 1.01 ± 0.03
prek-head run check-useless-excludes --all-files 13.3 ± 0.1 13.0 13.4 1.00

prek run identity --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run identity --all-files 11.4 ± 0.1 11.3 11.6 1.00
prek-head run identity --all-files 11.6 ± 0.2 11.3 12.3 1.02 ± 0.02

@j178 j178 force-pushed the auto-update-settings branch 3 times, most recently from dec2146 to 5b7e65f Compare May 4, 2026 14:20
@j178 j178 marked this pull request as ready for review May 4, 2026 14:20
Copilot AI review requested due to automatic review settings May 4, 2026 14:20
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

Adds a project-level auto_update.cooldown_days configuration so prek auto-update can default its cooldown window from the project config (YAML/TOML), with CLI override still taking precedence, and global config as fallback. This fits into prek’s configuration model by extending Config and routing cooldown resolution through workspace/project discovery so each project can be evaluated with its own cooldown.

Changes:

  • Extend project config model + JSON schema with auto_update.cooldown_days.
  • Resolve cooldown per project (CLI → project → global → default) and thread it through auto-update’s repo-target evaluation.
  • Update docs and integration tests/snapshots to cover workspace/project cooldown behavior.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
prek.schema.json Adds auto_update to the project config schema and defines AutoUpdateOptions.cooldown_days.
docs/reference/configuration.md Documents global vs project auto_update.cooldown_days and precedence rules.
docs/reference/cli.md Updates --cooldown-days help text to mention project config precedence.
docs/configuration.md Adds project config examples for auto_update.cooldown_days and lists it as a prek-only YAML extension.
crates/prek/tests/global_config.rs Adjusts global-config tests to run auto-update with a minimal project config present (and updates snapshots accordingly).
crates/prek/tests/auto_update.rs Adds a workspace test asserting per-project cooldown behavior when sharing the same repo URL.
crates/prek/src/snapshots/prek__config__tests__read_yaml_config.snap Updates config parsing snapshot to include the new auto_update field (default None).
crates/prek/src/snapshots/prek__config__tests__read_toml_config.snap Updates config parsing snapshot to include the new auto_update field (default None).
crates/prek/src/snapshots/prek__config__tests__read_config_with_nested_merge_keys.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__read_config_with_merge_keys.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__parse_repos.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__parse_repos-6.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__parse_repos-4.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__parse_repos-3.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__parse_hooks-3.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__numeric_rev_is_parsed_as_string.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__meta_hooks-5.snap Updates snapshot for new Config field.
crates/prek/src/snapshots/prek__config__tests__language_version.snap Updates snapshot for new Config field.
crates/prek/src/settings.rs Updates cooldown resolution logic to incorporate project-level cooldown (between CLI and global).
crates/prek/src/main.rs Passes cooldown + filesystem options into auto_update for per-project resolution; changes --show-settings behavior for this command.
crates/prek/src/hook.rs Updates an internal test Config literal to include the new auto_update field.
crates/prek/src/config.rs Introduces AutoUpdateOptions and adds Config.auto_update field (project-level).
crates/prek/src/cli/mod.rs Updates --cooldown-days docs to mention project config fallback.
crates/prek/src/cli/auto_update/source.rs Resolves cooldown per project and includes it in repo-target grouping + evaluation.
crates/prek/src/cli/auto_update/mod.rs Plumbs CLI cooldown + global filesystem options into repo source collection; drops global cooldown param from per-repo evaluation path.
Comments suppressed due to low confidence (1)

docs/reference/configuration.md:20

  • The docs describe auto_update.cooldown_days as an unconstrained “integer days”, but the implementation uses u8 (and the JSON schema enforces 0..=255). Document the valid range (or at least note the 255-day maximum) so users aren’t surprised by parse/CLI validation failures for larger values.
Default cooldown for `prek auto-update`.

- Type: integer days
- Default: `0`
- CLI override: `prek auto-update --cooldown-days <DAYS>`

Comment thread crates/prek/src/main.rs
Comment thread crates/prek/src/config.rs
Base automatically changed from global-config to master May 5, 2026 05:11
@j178 j178 force-pushed the auto-update-settings branch from 1ca704d to b66a0b4 Compare May 5, 2026 05:16
Copilot AI review requested due to automatic review settings May 5, 2026 05:26
@j178 j178 merged commit 5f94f6f into master May 5, 2026
33 checks passed
@j178 j178 deleted the auto-update-settings branch May 5, 2026 05:27
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: 525a0c428a

ℹ️ 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 thread crates/prek/src/main.rs
let filesystem = FilesystemOptions::user()?;
let settings = AutoUpdateSettings::resolve(&args, filesystem.as_ref());
show_settings!(settings);
show_settings!(args);
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 Preserve resolved settings in auto-update debug output

--show-settings is documented as showing resolved settings, but this branch now calls show_settings!(args) before running auto_update, so it prints only raw AutoUpdateArgs and exits without ever resolving project/global auto_update.cooldown_days precedence. In practice, prek auto-update --show-settings can no longer reveal the effective cooldown when it comes from config files, which is a regression for debugging configuration behavior.

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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Comment thread crates/prek/src/main.rs
Comment on lines 377 to 399
@@ -394,7 +393,8 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
args.jobs,
args.dry_run || args.check,
args.exit_code || args.check,
settings.cooldown_days,
args.cooldown_days,
filesystem,
printer,
)
Comment on lines +98 to 112
pub(crate) fn resolve(
cli_cooldown_days: Option<u8>,
filesystem: Option<&FilesystemOptions>,
project_cooldown_days: Option<u8>,
) -> Self {
Self {
cooldown_days: args
.cooldown_days
cooldown_days: cli_cooldown_days
.or(project_cooldown_days)
.or_else(|| {
filesystem
.and_then(|fs| fs.auto_update.as_ref())
.and_then(|au| au.cooldown_days)
.and_then(|options| options.cooldown_days)
})
.unwrap_or_default(),
}
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 --cooldown-days a top level key

2 participants