mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Merge pull request #1299 from pre-commit/hookspath_init_templatedir
allow init-templatedir to succeed when core.hooksPath is set
This commit is contained in:
commit
6c2a14839e
2 changed files with 12 additions and 1 deletions
|
|
@ -123,7 +123,7 @@ def install(
|
||||||
skip_on_missing_config: bool = False,
|
skip_on_missing_config: bool = False,
|
||||||
git_dir: Optional[str] = None,
|
git_dir: Optional[str] = None,
|
||||||
) -> int:
|
) -> int:
|
||||||
if git.has_core_hookpaths_set():
|
if git_dir is None and git.has_core_hookpaths_set():
|
||||||
logger.error(
|
logger.error(
|
||||||
'Cowardly refusing to install hooks with `core.hooksPath` set.\n'
|
'Cowardly refusing to install hooks with `core.hooksPath` set.\n'
|
||||||
'hint: `git config --unset-all core.hooksPath`',
|
'hint: `git config --unset-all core.hooksPath`',
|
||||||
|
|
|
||||||
|
|
@ -79,3 +79,14 @@ def test_init_templatedir_expanduser(tmpdir, tempdir_factory, store, cap_out):
|
||||||
lines = cap_out.get().splitlines()
|
lines = cap_out.get().splitlines()
|
||||||
assert len(lines) == 1
|
assert len(lines) == 1
|
||||||
assert lines[0].startswith('pre-commit installed at')
|
assert lines[0].startswith('pre-commit installed at')
|
||||||
|
|
||||||
|
|
||||||
|
def test_init_templatedir_hookspath_set(tmpdir, tempdir_factory, store):
|
||||||
|
target = tmpdir.join('tmpl')
|
||||||
|
tmp_git_dir = git_dir(tempdir_factory)
|
||||||
|
with cwd(tmp_git_dir):
|
||||||
|
cmd_output('git', 'config', '--local', 'core.hooksPath', 'hooks')
|
||||||
|
init_templatedir(
|
||||||
|
C.CONFIG_FILE, store, target, hook_types=['pre-commit'],
|
||||||
|
)
|
||||||
|
assert target.join('hooks/pre-commit').exists()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue