| 112 | |
| 113 | |
| 114 | def install( |
| 115 | config_file: str, |
| 116 | store: Store, |
| 117 | hook_types: list[str] | None, |
| 118 | overwrite: bool = False, |
| 119 | hooks: bool = False, |
| 120 | skip_on_missing_config: bool = False, |
| 121 | git_dir: str | None = None, |
| 122 | ) -> int: |
| 123 | if git_dir is None and git.has_core_hookpaths_set(): |
| 124 | logger.error( |
| 125 | 'Cowardly refusing to install hooks with `core.hooksPath` set.\n' |
| 126 | 'hint: `git config --unset-all core.hooksPath`', |
| 127 | ) |
| 128 | return 1 |
| 129 | |
| 130 | for hook_type in _hook_types(config_file, hook_types): |
| 131 | _install_hook_script( |
| 132 | config_file, hook_type, |
| 133 | overwrite=overwrite, |
| 134 | skip_on_missing_config=skip_on_missing_config, |
| 135 | git_dir=git_dir, |
| 136 | ) |
| 137 | |
| 138 | if hooks: |
| 139 | install_hooks(config_file, store) |
| 140 | |
| 141 | return 0 |
| 142 | |
| 143 | |
| 144 | def install_hooks(config_file: str, store: Store) -> int: |