mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 21:10:27 -06:00
28 lines
910 B
Python
28 lines
910 B
Python
import logging
|
|
import os.path
|
|
|
|
from pre_commit.commands.install_uninstall import install
|
|
from pre_commit.util import CalledProcessError
|
|
from pre_commit.util import cmd_output
|
|
|
|
logger = logging.getLogger('pre_commit')
|
|
|
|
|
|
def init_templatedir(config_file, store, directory, hook_types):
|
|
install(
|
|
config_file, store, hook_types=hook_types,
|
|
overwrite=True, skip_on_missing_config=True, git_dir=directory,
|
|
)
|
|
try:
|
|
_, out, _ = cmd_output('git', 'config', 'init.templateDir')
|
|
except CalledProcessError:
|
|
configured_path = None
|
|
else:
|
|
configured_path = os.path.realpath(os.path.expanduser(out.strip()))
|
|
dest = os.path.realpath(directory)
|
|
if configured_path != dest:
|
|
logger.warning('`init.templateDir` not set to the target directory')
|
|
logger.warning(
|
|
'maybe `git config --global init.templateDir {}`?'.format(dest),
|
|
)
|