Skip to content

Add --all flag to prek uninstall#1817

Merged
j178 merged 3 commits intoj178:masterfrom
Tiryoh:fix/uninstall-remove-all-managed-hooks
Mar 18, 2026
Merged

Add --all flag to prek uninstall#1817
j178 merged 3 commits intoj178:masterfrom
Tiryoh:fix/uninstall-remove-all-managed-hooks

Conversation

@Tiryoh
Copy link
Copy Markdown
Contributor

@Tiryoh Tiryoh commented Mar 17, 2026

Summary

Closes #1779

  • Add --all flag to prek uninstall that scans the hooks directory and removes every prek-managed hook (detected via is_our_script()), regardless of hook type
  • Without --all, behavior is unchanged: uses -t or default_install_hook_types, falls back to pre-commit
  • --all and -t are mutually exclusive (conflicts_with)
  • Suppress "not managed" / "does not exist" skip messages when --all is used, since iterating all hook types will naturally hit many non-existent ones

Tests

  • uninstall_all_managed_hooks: --all removes all prek-managed hooks
  • uninstall_all_no_hooks: --all exits cleanly when no hooks are installed
  • Ran mise run lint and confirmed no errors

`prek uninstall` previously only removed the default hook types unless
`-t` was specified, which could leave other prek-managed hooks behind.
Add an explicit `--all` flag to remove every prek-managed hook from
`.git/hooks`, while keeping the default behavior limited to configured
hook types or `pre-commit`.

Also suppress skip messages during `--all` scans and add tests for
removing multiple hooks and for the no-op case.
@Tiryoh Tiryoh requested a review from j178 as a code owner March 17, 2026 15:53
Copilot AI review requested due to automatic review settings March 17, 2026 15:53
@Tiryoh Tiryoh marked this pull request as draft March 17, 2026 15:54
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.72%. Comparing base (9782923) to head (5267a71).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
crates/prek/src/cli/install.rs 88.23% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1817   +/-   ##
=======================================
  Coverage   91.72%   91.72%           
=======================================
  Files          98       98           
  Lines       20055    20063    +8     
=======================================
+ Hits        18395    18403    +8     
  Misses       1660     1660           

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

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 an --all flag to the prek uninstall subcommand so users can remove every prek-managed Git hook shim in one go, addressing the longstanding UX gap where uninstall could leave other installed hook types behind.

Changes:

  • Add --all to prek uninstall, mutually exclusive with -t/--hook-type.
  • Implement --all behavior by iterating all supported HookType variants and removing those detected as prek-managed via is_our_script().
  • Add integration tests/snapshots validating --all removes multiple hooks and no-ops cleanly when nothing is installed.

Reviewed changes

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

File Description
crates/prek/src/cli/mod.rs Adds the --all flag to UninstallArgs and documents/conflicts it with --hook-type.
crates/prek/src/main.rs Wires the new args.all flag through to the uninstall handler.
crates/prek/src/cli/install.rs Implements the uninstall --all logic and suppresses skip messages when iterating all hook types.
crates/prek/tests/install.rs Adds snapshot tests covering prek uninstall --all behavior.

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot bot commented Mar 17, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (24.8 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%  73.1KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  69.0KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.6%  68.5KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.4%  51.0KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4%  50.6KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4%  46.5KiB              prek prek::run::{{closure}}
 0.2%   0.3%  41.8KiB              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.0KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.8KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble
 0.1%   0.2%  26.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%  25.9KiB              prek prek::cli::try_repo::try_repo::{{closure}}
 0.1%   0.2%  23.0KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2%  22.4KiB      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.7KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  21.7KiB              prek prek::workspace::Project::init_hooks::{{closure}}
41.1%  86.0%  10.2MiB                   And 23309 smaller methods. Use -n N to show more.
47.8% 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%  73.1KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6%  68.4KiB              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.2%   0.4%  51.0KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4%  50.6KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4%  45.6KiB              prek prek::run::{{closure}}
 0.2%   0.3%  41.9KiB              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.0KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble_alt
 0.1%   0.2%  27.8KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2%  27.5KiB        aws_lc_sys aws_lc_0_38_0_edwards25519_scalarmuldouble
 0.1%   0.2%  26.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%  25.9KiB              prek prek::cli::try_repo::try_repo::{{closure}}
 0.1%   0.2%  23.0KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2%  22.4KiB      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.7KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2%  21.7KiB              prek prek::workspace::Project::init_hooks::{{closure}}
41.1%  86.0%  10.2MiB                   And 23304 smaller methods. Use -n N to show more.
47.8% 100.0%  11.9MiB                   .text section size, the file size is 24.8MiB

@prek-ci-bot
Copy link
Copy Markdown

prek-ci-bot bot commented Mar 17, 2026

⚡️ Hyperfine Benchmarks

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

Environment
  • OS: Linux 6.14.0-1017-azure
  • CPU: 4 cores
  • prek version: prek 0.3.6+10 (96b4eb2 2026-03-18)
  • Rust version: rustc 1.94.0 (4a4ef493e 2026-03-02)
  • 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 1.8 ± 0.2 1.6 3.5 1.01 ± 0.14
prek-head --version 1.8 ± 0.1 1.6 2.9 1.00

prek list

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base list 7.5 ± 0.7 7.1 12.1 1.02 ± 0.09
prek-head list 7.4 ± 0.2 7.1 8.6 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 2.5 ± 0.1 2.3 2.9 1.00 ± 0.13
prek-head validate-config .pre-commit-config.yaml 2.5 ± 0.3 2.3 4.4 1.00

prek sample-config

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base sample-config 2.1 ± 0.0 1.9 2.2 1.01 ± 0.03
prek-head sample-config 2.0 ± 0.0 1.9 2.2 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 99.3 ± 1.4 97.9 101.7 1.00 ± 0.02
prek-head run --all-files 99.0 ± 1.1 97.6 101.5 1.00

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

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --all-files 100.0 ± 1.3 98.3 102.6 1.00
prek-head run --all-files 100.4 ± 2.1 97.4 105.0 1.00 ± 0.02
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 100.6 ± 2.2 97.6 108.2 1.00
prek-head run --all-files 100.6 ± 3.2 97.0 119.9 1.00 ± 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 14.8 ± 0.6 14.0 16.8 1.00
prek-head run trailing-whitespace --all-files 15.1 ± 1.2 13.9 18.3 1.02 ± 0.09

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 18.8 ± 1.2 16.8 21.4 1.01 ± 0.09
prek-head run end-of-file-fixer --all-files 18.6 ± 1.1 17.2 22.0 1.00

prek run check-json --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-json --all-files 9.2 ± 0.4 8.7 10.7 1.03 ± 0.06
prek-head run check-json --all-files 9.0 ± 0.3 8.3 10.2 1.00

prek run check-yaml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-yaml --all-files 8.7 ± 1.0 8.2 13.9 1.03 ± 0.12
prek-head run check-yaml --all-files 8.4 ± 0.2 8.1 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.4 ± 0.2 8.1 8.8 1.02 ± 0.03
prek-head run check-toml --all-files 8.3 ± 0.1 7.9 8.5 1.00

prek run check-xml --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run check-xml --all-files 8.5 ± 0.3 8.1 9.2 1.02 ± 0.04
prek-head run check-xml --all-files 8.3 ± 0.2 8.0 8.8 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 13.1 ± 0.8 11.6 15.8 1.00
prek-head run detect-private-key --all-files 13.1 ± 0.7 11.8 14.8 1.01 ± 0.08

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 16.5 ± 1.8 14.4 24.0 1.00
prek-head run fix-byte-order-marker --all-files 16.9 ± 0.9 15.5 18.4 1.02 ± 0.12
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 3.7 ± 0.1 3.6 3.9 1.00 ± 0.04
prek-head install-hooks 3.7 ± 0.1 3.6 3.8 1.00

prek install-hooks (warm - with cache)

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base install-hooks 3.7 ± 0.1 3.5 3.8 1.00
prek-head install-hooks 3.7 ± 0.1 3.7 3.8 1.01 ± 0.03
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 36.3 ± 1.1 34.8 39.3 1.00
prek-head run 36.7 ± 1.2 35.3 40.4 1.01 ± 0.05

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

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run --files '*.json' 6.3 ± 0.1 6.0 6.6 1.00
prek-head run --files '*.json' 6.5 ± 0.3 6.2 7.8 1.03 ± 0.06
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 9.6 ± 0.2 9.4 10.1 1.01 ± 0.03
prek-head run --dry-run --all-files 9.5 ± 0.2 9.2 10.0 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 9.8 ± 0.1 9.6 10.1 1.01 ± 0.02
prek-head run check-hooks-apply --all-files 9.7 ± 0.2 9.5 10.3 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 9.8 ± 0.3 9.5 10.3 1.02 ± 0.03
prek-head run check-useless-excludes --all-files 9.7 ± 0.2 9.3 9.9 1.00

prek run identity --all-files

Command Mean [ms] Min [ms] Max [ms] Relative
prek-base run identity --all-files 7.9 ± 0.3 7.5 8.4 1.04 ± 0.05
prek-head run identity --all-files 7.6 ± 0.1 7.5 7.9 1.00

@Tiryoh Tiryoh force-pushed the fix/uninstall-remove-all-managed-hooks branch from b86fb0f to 9e5a7f3 Compare March 17, 2026 16:01
@Tiryoh Tiryoh marked this pull request as ready for review March 17, 2026 16:07
Copilot AI review requested due to automatic review settings March 17, 2026 16:07
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 an --all flag to the prek uninstall subcommand to remove all prek-managed Git hook shims (as detected by is_our_script()), while keeping existing uninstall behavior unchanged unless the flag is provided.

Changes:

  • Add --all to prek uninstall and wire it through CLI parsing to uninstall logic.
  • When --all is used, iterate over hook types and suppress “not managed” / “does not exist” skip messages.
  • Add integration tests covering --all uninstall behavior with multiple hooks and with no hooks installed.

Reviewed changes

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

Show a summary per file
File Description
docs/cli.md Documents the new --all option for prek uninstall.
crates/prek/tests/install.rs Adds tests/snapshots for prek uninstall --all.
crates/prek/src/main.rs Passes the parsed --all flag into the uninstall handler.
crates/prek/src/cli/mod.rs Adds the --all flag to UninstallArgs with a conflicts_with rule.
crates/prek/src/cli/install.rs Implements --all behavior by iterating hook types and suppressing certain skip messages.

Copilot AI review requested due to automatic review settings March 18, 2026 05:03
@j178 j178 force-pushed the fix/uninstall-remove-all-managed-hooks branch from 661cde5 to 5267a71 Compare March 18, 2026 05:03
@j178 j178 added the enhancement New feature or request label Mar 18, 2026
@j178 j178 enabled auto-merge (squash) March 18, 2026 05:03
@j178
Copy link
Copy Markdown
Owner

j178 commented Mar 18, 2026

Thank you!

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 an --all option to prek uninstall to remove all prek-managed Git hook shims, making it easier to clean up across hook types.

Changes:

  • Introduce --all flag for prek uninstall (conflicts with --hook-type) and plumb it through the CLI.
  • Update uninstall behavior to iterate all supported hook types when --all is set (and suppress “skipping” noise).
  • Add an integration test covering prek uninstall --all behavior and update CLI reference docs.

Reviewed changes

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

Show a summary per file
File Description
docs/cli.md Documents the new --all option in the generated CLI reference.
crates/prek/tests/install.rs Adds an integration test verifying --all removes managed hooks while leaving non-managed hooks intact.
crates/prek/src/main.rs Wires the new args.all flag into the uninstall command invocation.
crates/prek/src/cli/mod.rs Adds --all flag to UninstallArgs and updates help text.
crates/prek/src/cli/install.rs Implements --all behavior by uninstalling across all supported HookType variants and reducing skip output.

@j178 j178 disabled auto-merge March 18, 2026 05:09
@j178 j178 merged commit 47c017a into j178:master Mar 18, 2026
54 checks passed
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.

prek uninstall without -t should remove all prek-managed hooks

3 participants