Skip to content

fix: uninstall without -t removes all pre-commit managed hooks#3633

Closed
Tiryoh wants to merge 1 commit intopre-commit:mainfrom
Tiryoh:feature/update-uninstall-command
Closed

fix: uninstall without -t removes all pre-commit managed hooks#3633
Tiryoh wants to merge 1 commit intopre-commit:mainfrom
Tiryoh:feature/update-uninstall-command

Conversation

@Tiryoh
Copy link

@Tiryoh Tiryoh commented Mar 11, 2026

Summary

Closes #364

Thanks for maintaining this project for so long. I saw the "patches welcome" comment on #364 back in 2018 — is this kind of change still acceptable?

pre-commit uninstall without -t only removed hooks based on default_install_hook_types from the config. This meant hooks installed with e.g. -t pre-push would silently remain unless explicitly uninstalled with -t pre-push.

This change makes uninstall without -t scan all known HOOK_TYPES and remove any managed by pre-commit (checked via is_our_script). Non-pre-commit hooks are left untouched.

  • -t specified: behavior unchanged
  • -t not specified: removes all pre-commit managed hooks
  • install: behavior unchanged (still respects default_install_hook_types)

Test plan

  • Existing uninstall tests pass
  • test_uninstall_without_t_removes_all_hooks — installs multiple hook types, uninstalls without -t, all removed
  • test_uninstall_without_t_ignores_non_precommit_hooks — custom hooks are preserved

Previously, `pre-commit uninstall` without `-t` only removed hooks
listed in `default_install_hook_types` from the config. This meant
hooks installed with e.g. `-t pre-push` would not be removed unless
`-t pre-push` was explicitly passed to uninstall.

Now, when `-t` is not specified, uninstall scans all known hook types
and removes any that are managed by pre-commit (via `is_our_script`).

Fixes pre-commit#364

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@asottile
Copy link
Member

ai slop is not acceptable and I'm not changing the behavior either way

@asottile asottile closed this Mar 11, 2026
@Tiryoh
Copy link
Author

Tiryoh commented Mar 11, 2026

Understood — thanks for clarifying.

For the record: this PR was based on issue #364 where the change was mentioned as “patches welcome”. As that discussion is quite old, the current behavior being intentional makes sense.

I'll drop the change.
Thanks.

@asottile
Copy link
Member

a lot has changed in nearly a decade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

pre-commit uninstall does not remove pre-push hooks

2 participants