Allow --hook-type to be specified multiple times

This commit is contained in:
Anthony Sottile 2019-09-23 11:14:36 -07:00
parent 96c35185f0
commit a18646deb2
6 changed files with 119 additions and 79 deletions

View file

@ -16,7 +16,7 @@ from testing.util import git_commit
def test_init_templatedir(tmpdir, tempdir_factory, store, cap_out):
target = str(tmpdir.join('tmpl'))
init_templatedir(C.CONFIG_FILE, store, target, hook_type='pre-commit')
init_templatedir(C.CONFIG_FILE, store, target, hook_types=['pre-commit'])
lines = cap_out.get().splitlines()
assert lines[0].startswith('pre-commit installed at ')
assert lines[1] == (
@ -45,7 +45,9 @@ def test_init_templatedir_already_set(tmpdir, tempdir_factory, store, cap_out):
tmp_git_dir = git_dir(tempdir_factory)
with cwd(tmp_git_dir):
cmd_output('git', 'config', 'init.templateDir', target)
init_templatedir(C.CONFIG_FILE, store, target, hook_type='pre-commit')
init_templatedir(
C.CONFIG_FILE, store, target, hook_types=['pre-commit'],
)
lines = cap_out.get().splitlines()
assert len(lines) == 1
@ -57,7 +59,9 @@ def test_init_templatedir_not_set(tmpdir, store, cap_out):
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')
init_templatedir(
C.CONFIG_FILE, store, '.', hook_types=['pre-commit'],
)
lines = cap_out.get().splitlines()
assert len(lines) == 3
@ -73,7 +77,7 @@ def test_init_templatedir_expanduser(tmpdir, tempdir_factory, store, cap_out):
cmd_output('git', 'config', 'init.templateDir', '~/templatedir')
with mock.patch.object(os.path, 'expanduser', return_value=target):
init_templatedir(
C.CONFIG_FILE, store, target, hook_type='pre-commit',
C.CONFIG_FILE, store, target, hook_types=['pre-commit'],
)
lines = cap_out.get().splitlines()