Skip to content

Support legacy mode hook script#1706

Merged
j178 merged 2 commits intomasterfrom
legacy
Mar 4, 2026
Merged

Support legacy mode hook script#1706
j178 merged 2 commits intomasterfrom
legacy

Conversation

@j178
Copy link
Owner

@j178 j178 commented Feb 28, 2026

Closes #1700

Copilot AI review requested due to automatic review settings February 28, 2026 17:55
@j178 j178 added the enhancement New feature or request label Feb 28, 2026
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

❌ Patch coverage is 96.07843% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.63%. Comparing base (0c019aa) to head (8a2e897).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
crates/prek/src/cli/hook_impl.rs 92.30% 5 Missing ⚠️
crates/prek/src/cli/install.rs 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1706      +/-   ##
==========================================
+ Coverage   91.59%   91.63%   +0.04%     
==========================================
  Files          98       98              
  Lines       19324    19459     +135     
==========================================
+ Hits        17699    17831     +132     
- Misses       1625     1628       +3     

☔ 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

prek-ci-bot bot commented Feb 28, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.40% (24.7 MiB → 24.8 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size             Crate Name
 1.3%   2.7% 332.0KiB        aws_lc_sys aws_lc_0_38_0_aes_gcm_encrypt_avx512
 1.3%   2.7% 332.0KiB        aws_lc_sys aws_lc_0_38_0_aes_gcm_decrypt_avx512
 0.3%   0.6%  70.7KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  67.4KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.5%  65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.4%  51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4%  50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4%  45.5KiB              prek prek::run::{{closure}}
 0.2%   0.3%  41.7KiB              prek prek::cli::run::run::run::{{closure}}
 0.1%   0.3%  31.8KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  28.5KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble
 0.1%   0.2%  24.7KiB             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%  22.8KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  22.3KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2%  22.3KiB         [Unknown] Lp384_montjscalarmul_alt_p384_montjadd
 0.1%   0.2%  21.9KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  21.5KiB         [Unknown] Lp384_montjscalarmul_p384_montjadd
 0.1%   0.2%  21.5KiB              prek prek::languages::ruby::installer::RubyInstaller::install::{{closure}}
41.4%  86.2%  10.2MiB                   And 23478 smaller methods. Use -n N to show more.
48.0% 100.0%  11.9MiB                   .text section size, the file size is 24.8MiB

Base Branch Results

 File  .text     Size             Crate Name
 1.3%   2.7% 332.0KiB        aws_lc_sys aws_lc_0_38_0_aes_gcm_encrypt_avx512
 1.3%   2.7% 332.0KiB        aws_lc_sys aws_lc_0_38_0_aes_gcm_decrypt_avx512
 0.3%   0.6%  71.3KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  68.0KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.5%  65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.4%  51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4%  50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.3%  41.1KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.3%  39.5KiB              prek prek::run::{{closure}}
 0.1%   0.3%  32.0KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  28.5KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  28.0KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble
 0.1%   0.2%  24.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%  22.8KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  22.7KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2%  22.3KiB         [Unknown] Lp384_montjscalarmul_alt_p384_montjadd
 0.1%   0.2%  21.9KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  21.5KiB         [Unknown] Lp384_montjscalarmul_p384_montjadd
 0.1%   0.2%  21.4KiB              prek prek::languages::ruby::installer::RubyInstaller::install::{{closure}}
41.3%  86.2%  10.2MiB                   And 23463 smaller methods. Use -n N to show more.
48.0% 100.0%  11.9MiB                   .text section size, the file size is 24.7MiB

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

Adds support for running “legacy mode” Git hook scripts alongside (or in place of) prek’s hook implementation, enabling hook migration via <hook_type>.legacy scripts in the hooks directory.

Changes:

  • Execute an executable {hook_type}.legacy hook (with recursion guard) and merge its exit status with prek’s.
  • Capture pre-push stdin once and reuse it for both legacy hook execution and push-info parsing.
  • Add Unix-only integration tests covering legacy hook execution for pre-commit and pre-push.

Reviewed changes

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

File Description
crates/prek/src/cli/hook_impl.rs Runs legacy hooks, captures stdin for pre-push, and combines legacy+prek exit statuses.
crates/prek/src/cli/mod.rs Adds From<u8> for ExitStatus to convert legacy exit codes.
crates/prek-consts/src/env_vars.rs Introduces PREK_RUNNING_LEGACY env var constant for recursion prevention.
crates/prek/tests/hook_impl.rs Adds Unix-only tests validating legacy hook behavior.

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

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

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

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

Copilot AI review requested due to automatic review settings March 4, 2026 18:09
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings March 4, 2026 18:20
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

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

@j178 j178 merged commit a356523 into master Mar 4, 2026
52 checks passed
@j178 j178 deleted the legacy branch March 4, 2026 18:27
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.

Legacy mode is not implemented

2 participants