MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / init_templatedir

Function init_templatedir

pre_commit/commands/init_templatedir.py:14–39  ·  view source on GitHub ↗
(
        config_file: str,
        store: Store,
        directory: str,
        hook_types: list[str] | None,
        skip_on_missing_config: bool = True,
)

Source from the content-addressed store, hash-verified

12
13
14def init_templatedir(
15 config_file: str,
16 store: Store,
17 directory: str,
18 hook_types: list[str] | None,
19 skip_on_missing_config: bool = True,
20) -> int:
21 install(
22 config_file,
23 store,
24 hook_types=hook_types,
25 overwrite=True,
26 skip_on_missing_config=skip_on_missing_config,
27 git_dir=directory,
28 )
29 try:
30 _, out, _ = cmd_output('git', 'config', 'init.templateDir')
31 except CalledProcessError:
32 configured_path = None
33 else:
34 configured_path = os.path.realpath(os.path.expanduser(out.strip()))
35 dest = os.path.realpath(directory)
36 if configured_path != dest:
37 logger.warning('`init.templateDir` not set to the target directory')
38 logger.warning(f'maybe `git config --global init.templateDir {dest}`?')
39 return 0

Calls 2

installFunction · 0.90
cmd_outputFunction · 0.90