mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 01:51:46 +04:00
fix uninstall without -t to remove all pre-commit managed hooks
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 #364 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8416413a0e
commit
16f7c46de5
2 changed files with 29 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import sys
|
|||
|
||||
from pre_commit import git
|
||||
from pre_commit import output
|
||||
from pre_commit.clientlib import HOOK_TYPES
|
||||
from pre_commit.clientlib import InvalidConfigError
|
||||
from pre_commit.clientlib import load_config
|
||||
from pre_commit.repository import all_hooks
|
||||
|
|
@ -162,6 +163,10 @@ def _uninstall_hook_script(hook_type: str) -> None:
|
|||
|
||||
|
||||
def uninstall(config_file: str, hook_types: list[str] | None) -> int:
|
||||
for hook_type in _hook_types(config_file, hook_types):
|
||||
if hook_types is not None:
|
||||
actual_hook_types = hook_types
|
||||
else:
|
||||
actual_hook_types = list(HOOK_TYPES)
|
||||
for hook_type in actual_hook_types:
|
||||
_uninstall_hook_script(hook_type)
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue