mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Allow --hook-type to be specified multiple times
This commit is contained in:
parent
96c35185f0
commit
a18646deb2
6 changed files with 119 additions and 79 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue