Don't treat unset init.templateDir as the current directory

This commit is contained in:
Anthony Sottile 2019-08-03 11:42:18 -07:00
parent da80cc6479
commit cab8036db3
2 changed files with 22 additions and 2 deletions

View file

@ -47,3 +47,17 @@ def test_init_templatedir_already_set(tmpdir, tempdir_factory, store, cap_out):
lines = cap_out.get().splitlines()
assert len(lines) == 1
assert lines[0].startswith('pre-commit installed at')
def test_init_templatedir_not_set(tmpdir, store, cap_out):
# set HOME to ignore the current `.gitconfig`
with envcontext([('HOME', str(tmpdir))]):
with tmpdir.join('tmpl').ensure_dir().as_cwd():
# we have not set init.templateDir so this should produce a warning
init_templatedir(C.CONFIG_FILE, store, '.', hook_type='pre-commit')
lines = cap_out.get().splitlines()
assert len(lines) == 3
assert lines[1] == (
'[WARNING] `init.templateDir` not set to the target directory'
)