@@ -67,19 +67,10 @@ def shebang():
6767 return '#!/usr/bin/env {}' .format (py )
6868
6969
70- def install (
71- config_file , store ,
72- overwrite = False , hooks = False , hook_type = 'pre-commit' ,
73- skip_on_missing_config = False , git_dir = None ,
70+ def _install_hook_script (
71+ config_file , hook_type ,
72+ overwrite = False , skip_on_missing_config = False , git_dir = None ,
7473):
75- """Install the pre-commit hooks."""
76- if cmd_output ('git' , 'config' , 'core.hooksPath' , retcode = None )[1 ].strip ():
77- logger .error (
78- 'Cowardly refusing to install hooks with `core.hooksPath` set.\n '
79- 'hint: `git config --unset-all core.hooksPath`' ,
80- )
81- return 1
82-
8374 hook_path , legacy_path = _hook_paths (hook_type , git_dir = git_dir )
8475
8576 mkdirp (os .path .dirname (hook_path ))
@@ -120,7 +111,27 @@ def install(
120111
121112 output .write_line ('pre-commit installed at {}' .format (hook_path ))
122113
123- # If they requested we install all of the hooks, do so.
114+
115+ def install (
116+ config_file , store , hook_types ,
117+ overwrite = False , hooks = False ,
118+ skip_on_missing_config = False , git_dir = None ,
119+ ):
120+ if cmd_output ('git' , 'config' , 'core.hooksPath' , retcode = None )[1 ].strip ():
121+ logger .error (
122+ 'Cowardly refusing to install hooks with `core.hooksPath` set.\n '
123+ 'hint: `git config --unset-all core.hooksPath`' ,
124+ )
125+ return 1
126+
127+ for hook_type in hook_types :
128+ _install_hook_script (
129+ config_file , hook_type ,
130+ overwrite = overwrite ,
131+ skip_on_missing_config = skip_on_missing_config ,
132+ git_dir = git_dir ,
133+ )
134+
124135 if hooks :
125136 install_hooks (config_file , store )
126137
@@ -131,13 +142,12 @@ def install_hooks(config_file, store):
131142 install_hook_envs (all_hooks (load_config (config_file ), store ), store )
132143
133144
134- def uninstall (hook_type = 'pre-commit' ):
135- """Uninstall the pre-commit hooks."""
145+ def _uninstall_hook_script (hook_type ): # type: (str) -> None
136146 hook_path , legacy_path = _hook_paths (hook_type )
137147
138148 # If our file doesn't exist or it isn't ours, gtfo.
139149 if not os .path .exists (hook_path ) or not is_our_script (hook_path ):
140- return 0
150+ return
141151
142152 os .remove (hook_path )
143153 output .write_line ('{} uninstalled' .format (hook_type ))
@@ -146,4 +156,8 @@ def uninstall(hook_type='pre-commit'):
146156 os .rename (legacy_path , hook_path )
147157 output .write_line ('Restored previous hooks to {}' .format (hook_path ))
148158
159+
160+ def uninstall (hook_types ):
161+ for hook_type in hook_types :
162+ _uninstall_hook_script (hook_type )
149163 return 0
0 commit comments