MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / _ask_hook_installer

Method _ask_hook_installer

commitizen/commands/init.py:176–197  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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(

Callers 1

__call__Method · 0.95

Calls 2

InitFailedErrorClass · 0.90
unsafe_askMethod · 0.80

Tested by

no test coverage detected