mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Implement default_stages
This commit is contained in:
parent
9c6a1d80d6
commit
bd65d8947f
4 changed files with 29 additions and 3 deletions
|
|
@ -715,6 +715,7 @@ def test_local_python_repo(store, local_python_config):
|
|||
def test_default_language_version(store, local_python_config):
|
||||
config = {
|
||||
'default_language_version': {'python': 'fake'},
|
||||
'default_stages': ['commit'],
|
||||
'repos': [local_python_config],
|
||||
}
|
||||
|
||||
|
|
@ -728,6 +729,23 @@ def test_default_language_version(store, local_python_config):
|
|||
assert hook.language_version == 'fake2'
|
||||
|
||||
|
||||
def test_default_stages(store, local_python_config):
|
||||
config = {
|
||||
'default_language_version': {'python': C.DEFAULT},
|
||||
'default_stages': ['commit'],
|
||||
'repos': [local_python_config],
|
||||
}
|
||||
|
||||
# `stages` was not set, should default
|
||||
hook, = all_hooks(config, store)
|
||||
assert hook.stages == ['commit']
|
||||
|
||||
# `stages` is set, should not default
|
||||
config['repos'][0]['hooks'][0]['stages'] = ['push']
|
||||
hook, = all_hooks(config, store)
|
||||
assert hook.stages == ['push']
|
||||
|
||||
|
||||
def test_hook_id_not_present(tempdir_factory, store, fake_log_handler):
|
||||
path = make_repo(tempdir_factory, 'script_hooks_repo')
|
||||
config = make_config_from_repo(path)
|
||||
|
|
@ -786,13 +804,13 @@ def test_manifest_hooks(tempdir_factory, store):
|
|||
files='',
|
||||
id='bash_hook',
|
||||
language='script',
|
||||
language_version=C.DEFAULT,
|
||||
language_version='default',
|
||||
log_file='',
|
||||
minimum_pre_commit_version='0',
|
||||
name='Bash hook',
|
||||
pass_filenames=True,
|
||||
require_serial=False,
|
||||
stages=[],
|
||||
stages=('commit', 'commit-msg', 'manual', 'push'),
|
||||
types=['file'],
|
||||
verbose=False,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue