Skip to content

Revert pass-through of global install flags into generated hook scripts#1966

Merged
j178 merged 1 commit into
v04from
r1676
Apr 20, 2026
Merged

Revert pass-through of global install flags into generated hook scripts#1966
j178 merged 1 commit into
v04from
r1676

Conversation

@j178
Copy link
Copy Markdown
Owner

@j178 j178 commented Apr 20, 2026

Closes #1965

Reverts #1753.

I agree that passing global flags down into installed scripts is not a good idea, so this reverts that behavior. We can add dedicated install flags later if we want explicit inherit behavior.

…ll into generated hook scripts (#1753)"

This reverts commit 8501ccb.
Copilot AI review requested due to automatic review settings April 20, 2026 11:39
@j178 j178 added the breaking Breaking changes label Apr 20, 2026 — with ChatGPT Codex Connector
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v04@c6ac886). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff           @@
##             v04    #1966   +/-   ##
======================================
  Coverage       ?   92.08%           
======================================
  Files          ?      116           
  Lines          ?    23170           
  Branches       ?        0           
======================================
  Hits           ?    21335           
  Misses         ?     1835           
  Partials       ?        0           

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

@j178 j178 changed the base branch from master to v04 April 20, 2026 11:41
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

Reverts the behavior where prek install propagated global flags (e.g., -q/-v/--no-progress) into the generated Git hook scripts, aligning CLI semantics with user expectations and issue #1965. The PR also removes support for using absolute executable paths as language_version requests for several languages.

Changes:

  • Stop embedding global CLI flags into generated hook scripts (and simplify install/init-template-dir wiring).
  • Remove absolute-path language_version request support for Bun/Go/Node/Python/Ruby (docs + parsing/matching updates, tests adjusted).
  • Update integration tests/snapshots and language version matching APIs accordingly.

Reviewed changes

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

Show a summary per file
File Description
docs/languages.md Removes documentation implying absolute-path language_version support.
docs/configuration.md Updates Python language_version description to omit interpreter-path wording.
crates/prek/tests/languages/ruby.rs Drops the path-based Ruby language_version scenario from integration tests/snapshots.
crates/prek/tests/install.rs Removes install-flag propagation tests (quiet/verbose/no-progress).
crates/prek/src/main.rs Stops passing global quiet/verbose/no-progress into install/init-template-dir.
crates/prek/src/cli/install.rs Removes global-flag passthrough into hook script template and deletes related helper.
crates/prek/src/languages/rust/{version.rs,installer.rs} Simplifies matching API (removes unused toolchain param) and updates call sites/tests.
crates/prek/src/languages/ruby/{version.rs,installer.rs} Removes path request support; updates matching and installer logic/tests.
crates/prek/src/languages/python/{version.rs,python.rs} Removes path request support and updates uv request rendering + tests.
crates/prek/src/languages/node/{version.rs,installer.rs} Removes path request support and updates matching/installer logic + tests.
crates/prek/src/languages/golang/{version.rs,installer.rs} Removes path request support and updates matching/installer logic + tests.
crates/prek/src/languages/bun/{version.rs,installer.rs} Removes path request support and updates matching/installer logic + tests.

Comment on lines 169 to 171
#[test]
fn install_with_git_dir() {
let context = TestContext::new();
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The removed install_with_quiet_flag / install_with_silent_flag / install_with_verbose_flag / install_with_no_progress_flag tests previously ensured global flags were not baked into the generated hook script. Since the default install snapshot won’t catch regressions that only happen when prek install is invoked with -q/-v/--no-progress, consider reintroducing at least one targeted test that runs install -q (or similar) and asserts the installed script does not contain those flags.

Copilot generated this review using guidance from repository custom instructions.
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: cc0ea651d8

ℹ️ 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".

fi

exec "$PREK" [PREK_GLOBAL_ARGS]hook-impl --hook-dir "$HERE" --script-version [CUR_SCRIPT_VERSION] [PREK_ARGS] -- "$@"
exec "$PREK" hook-impl --hook-dir "$HERE" --script-version [CUR_SCRIPT_VERSION] [PREK_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 Bump hook script version after changing shim template

The generated hook command was changed here to remove inherited global flags, but CUR_SCRIPT_VERSION remains 4, and hook_impl only warns about outdated shims when the script version changes. That means repos that already have hooks installed from the previous template (also stamped as version 4, with -q/-v/--no-progress embedded) will keep the old behavior with no reinstall warning, so this revert does not actually take effect for existing installs unless users manually rerun prek install.

Useful? React with 👍 / 👎.

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot Bot commented Apr 20, 2026

📦 Cargo Bloat Comparison

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

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size             Crate Name
 1.3%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_39_1_aes_gcm_encrypt_avx512
 1.3%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_39_1_aes_gcm_decrypt_avx512
 0.3%   0.7%  86.9KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  84.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  72.2KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.5%  56.7KiB              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%  45.6KiB              prek prek::run::{{closure}}
 0.2%   0.3%  41.0KiB              prek prek::cli::run::run::run::{{closure}}
 0.1%   0.3%  33.3KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  30.2KiB             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.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.9KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  26.3KiB              prek prek::cli::try_repo::try_repo::{{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              prek prek::workspace::Project::init_hooks::{{closure}}
 0.1%   0.2%  21.5KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
41.1%  86.1%  10.6MiB                   And 23604 smaller methods. Use -n N to show more.
47.7% 100.0%  12.3MiB                   .text section size, the file size is 25.8MiB

Base Branch Results

 File  .text     Size             Crate Name
 1.3%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_39_1_aes_gcm_encrypt_avx512
 1.3%   2.6% 332.0KiB        aws_lc_sys aws_lc_0_39_1_aes_gcm_decrypt_avx512
 0.3%   0.7%  86.9KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  79.7KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  71.5KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.5%  56.7KiB              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%  45.6KiB              prek prek::run::{{closure}}
 0.2%   0.3%  41.3KiB              prek prek::cli::run::run::run::{{closure}}
 0.1%   0.3%  33.3KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.2%  30.2KiB             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.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%  27.2KiB              prek prek::cli::try_repo::try_repo::{{closure}}
 0.1%   0.2%  26.9KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{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              prek prek::workspace::Project::init_hooks::{{closure}}
 0.1%   0.2%  21.5KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
41.1%  86.2%  10.6MiB                   And 23610 smaller methods. Use -n N to show more.
47.7% 100.0%  12.3MiB                   .text section size, the file size is 25.8MiB

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot Bot commented Apr 20, 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.9+24 (cdca9f7 2026-04-20)
  • 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.2 ± 0.1 2.1 2.9 1.02 ± 0.06
prek-head --version 2.2 ± 0.1 2.1 2.6 1.00

prek list

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base list 9.0 ± 0.3 8.6 11.0 1.02 ± 0.04
prek-head list 8.9 ± 0.2 8.6 10.0 1.00

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

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base validate-config .pre-commit-config.yaml 3.1 ± 0.1 2.9 3.2 1.01 ± 0.02
prek-head validate-config .pre-commit-config.yaml 3.0 ± 0.0 3.0 3.2 1.00

prek sample-config

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base sample-config 2.5 ± 0.0 2.4 2.6 1.00
prek-head sample-config 2.5 ± 0.0 2.4 2.6 1.00 ± 0.02
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 142.0 ± 3.4 136.9 147.9 1.02 ± 0.03
prek-head run --all-files 139.2 ± 2.8 133.9 142.5 1.00

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

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --all-files 139.4 ± 4.0 133.8 145.0 1.01 ± 0.03
prek-head run --all-files 138.2 ± 2.6 134.3 143.0 1.00
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 137.4 ± 2.9 132.7 143.6 1.00
prek-head run --all-files 139.2 ± 3.9 131.7 150.3 1.01 ± 0.04
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 20.2 ± 0.6 19.3 21.9 1.02 ± 0.04
prek-head run trailing-whitespace --all-files 19.8 ± 0.4 19.0 20.6 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 36.6 ± 37.7 23.3 217.4 1.36 ± 1.41
prek-head run end-of-file-fixer --all-files 26.9 ± 2.2 23.2 31.0 1.00

prek run check-json --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-json --all-files 11.7 ± 0.3 10.9 12.5 1.04 ± 0.04
prek-head run check-json --all-files 11.2 ± 0.3 10.8 11.8 1.00

prek run check-yaml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-yaml --all-files 11.0 ± 0.2 10.7 11.4 1.00
prek-head run check-yaml --all-files 11.3 ± 0.2 11.0 11.7 1.03 ± 0.02

prek run check-toml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-toml --all-files 11.2 ± 0.4 10.5 11.9 1.00
prek-head run check-toml --all-files 11.4 ± 0.2 10.9 11.7 1.02 ± 0.04

prek run check-xml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-xml --all-files 11.2 ± 0.3 10.7 11.7 1.00
prek-head run check-xml --all-files 11.2 ± 0.2 10.8 11.7 1.00 ± 0.03

prek run detect-private-key --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run detect-private-key --all-files 17.2 ± 1.3 15.4 20.4 1.00
prek-head run detect-private-key --all-files 17.4 ± 1.2 15.3 21.0 1.01 ± 0.10

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 22.1 ± 1.5 19.3 24.7 1.00
prek-head run fix-byte-order-marker --all-files 22.4 ± 1.7 18.9 25.5 1.01 ± 0.10
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 4.5 ± 0.1 4.4 4.7 1.00
prek-head install-hooks 4.7 ± 0.4 4.4 5.5 1.04 ± 0.10

prek install-hooks (warm - with cache)

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base install-hooks 4.5 ± 0.0 4.4 4.5 1.00
prek-head install-hooks 4.5 ± 0.1 4.4 4.6 1.00 ± 0.02
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 47.9 ± 0.9 46.2 50.0 1.00
prek-head run 48.0 ± 1.3 46.0 52.6 1.00 ± 0.03

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

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --files '*.json' 8.3 ± 0.1 8.1 8.5 1.00
prek-head run --files '*.json' 8.5 ± 0.2 8.3 8.9 1.03 ± 0.03
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 12.8 ± 0.3 12.4 13.5 1.01 ± 0.03
prek-head run --dry-run --all-files 12.7 ± 0.2 12.4 13.1 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 12.4 ± 0.6 11.5 13.2 1.04 ± 0.06
prek-head run check-hooks-apply --all-files 11.9 ± 0.3 11.6 12.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 11.7 ± 0.1 11.4 11.9 1.01 ± 0.02
prek-head run check-useless-excludes --all-files 11.5 ± 0.2 11.2 11.8 1.00

prek run identity --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run identity --all-files 10.0 ± 0.1 9.9 10.2 1.00
prek-head run identity --all-files 10.1 ± 0.2 9.9 10.5 1.01 ± 0.02

@j178 j178 merged commit 520b742 into v04 Apr 20, 2026
60 checks passed
@j178 j178 deleted the r1676 branch April 20, 2026 11:48
j178 added a commit that referenced this pull request May 14, 2026
…ts (#1966)

Closes #1965

Reverts #1753.

I agree that passing global flags down into installed scripts is not a
good idea, so this reverts that behavior. We can add dedicated install
flags later if we want explicit inherit behavior.
j178 added a commit that referenced this pull request May 14, 2026
…ts (#1966)

Closes #1965

Reverts #1753.

I agree that passing global flags down into installed scripts is not a
good idea, so this reverts that behavior. We can add dedicated install
flags later if we want explicit inherit behavior.
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 19, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [prek](https://github.com/j178/prek) | minor | `0.3.13` → `0.4.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>j178/prek (prek)</summary>

### [`v0.4.0`](https://github.com/j178/prek/blob/HEAD/CHANGELOG.md#040)

[Compare Source](j178/prek@v0.3.13...v0.4.0)

Released on 2026-05-14.

##### Breaking changes

These are narrow cleanup breaks in behavior that was either temporary or never worked correctly. Most users should not need to change anything.

- Generated hook scripts no longer preserve `-q`, `-v`, or `--no-progress` passed to `prek install`. This only affects users who expected those global flags to be baked into installed hooks. ([#&#8203;1966](j178/prek#1966))
- `language_version` no longer accepts direct executable paths. Use `language_version: system` for a system toolchain, or use a supported version request instead. This path form did not work reliably before, so existing working configs should be unaffected. ([#&#8203;1831](j178/prek#1831))

##### Enhancements

- Expand tilde in `--config`, `--cd`, `--log-file` and `--git-dir` ([#&#8203;2063](j178/prek#2063))
- Prevent auto-update cooldown downgrades ([#&#8203;2055](j178/prek#2055))
- Use managed npm cache for node hooks ([#&#8203;2075](j178/prek#2075))

##### Bug fixes

- Fix npm config env overrides for node hooks ([#&#8203;2074](j178/prek#2074))

##### Documentation

- Add cookbook page for enabling Git 2.54 config-based global hooks ([#&#8203;2061](j178/prek#2061))

##### Contributors

- [@&#8203;j178](https://github.com/j178)

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzguMCIsInVwZGF0ZWRJblZlciI6IjQzLjE3OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prek install options are confusing

2 participants