Choose ``pre-commit`` or ``prek`` when installing Git hooks. Detection already accepts either tool, but install used to hard-code ``pre-commit``. Use the only available installer, or ask when both are on PATH.
(self)
| 174 | return hook_types |
| 175 | |
| 176 | def _ask_hook_installer(self) -> str: |
| 177 | """Choose ``pre-commit`` or ``prek`` when installing Git hooks. |
| 178 | |
| 179 | Detection already accepts either tool, but install used to |
| 180 | hard-code ``pre-commit``. Use the only available installer, or |
| 181 | ask when both are on PATH. |
| 182 | """ |
| 183 | installers = project_info.available_hook_installers() |
| 184 | if not installers: |
| 185 | raise InitFailedError( |
| 186 | "Failed to install pre-commit hook.\n" |
| 187 | "Neither pre-commit nor prek is installed in the current environment." |
| 188 | ) |
| 189 | if len(installers) == 1: |
| 190 | return installers[0] |
| 191 | |
| 192 | installer: str = questionary.select( |
| 193 | "Which hook installer do you want to use?", |
| 194 | choices=installers, |
| 195 | style=self.cz.style, |
| 196 | ).unsafe_ask() |
| 197 | return installer |
| 198 | |
| 199 | def _ask_config_path(self) -> Path: |
| 200 | filename: str = questionary.select( |
no test coverage detected