mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 01:51:46 +04:00
Implement pre-commit init-templatedir
This commit is contained in:
parent
3def940574
commit
9a52eefc99
7 changed files with 114 additions and 9 deletions
21
pre_commit/commands/init_templatedir.py
Normal file
21
pre_commit/commands/init_templatedir.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import logging
|
||||
import os.path
|
||||
|
||||
from pre_commit.commands.install_uninstall import install
|
||||
from pre_commit.util import cmd_output
|
||||
|
||||
logger = logging.getLogger('pre_commit')
|
||||
|
||||
|
||||
def init_templatedir(config_file, store, directory, hook_type):
|
||||
install(
|
||||
config_file, store, overwrite=True, hook_type=hook_type,
|
||||
skip_on_missing_config=True, git_dir=directory,
|
||||
)
|
||||
_, out, _ = cmd_output('git', 'config', 'init.templateDir', retcode=None)
|
||||
dest = os.path.realpath(directory)
|
||||
if os.path.realpath(out.strip()) != dest:
|
||||
logger.warning('`init.templateDir` not set to the target directory')
|
||||
logger.warning(
|
||||
'maybe `git config --global init.templateDir {}`?'.format(dest),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue