mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Implement default_stages
This commit is contained in:
parent
9c6a1d80d6
commit
bd65d8947f
4 changed files with 29 additions and 3 deletions
|
|
@ -224,6 +224,11 @@ CONFIG_SCHEMA = cfgv.Map(
|
|||
cfgv.OptionalRecurse(
|
||||
'default_language_version', DEFAULT_LANGUAGE_VERSION, {},
|
||||
),
|
||||
cfgv.Optional(
|
||||
'default_stages',
|
||||
cfgv.check_array(cfgv.check_one_of(C.STAGES)),
|
||||
C.STAGES,
|
||||
),
|
||||
cfgv.Optional('exclude', cfgv.check_regex, '^$'),
|
||||
cfgv.Optional('fail_fast', cfgv.check_bool, False),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ def run(config_file, store, args, environ=os.environ):
|
|||
hook
|
||||
for hook in all_hooks(config, store)
|
||||
if not args.hook or hook.id == args.hook or hook.alias == args.hook
|
||||
if not hook.stages or args.hook_stage in hook.stages
|
||||
if args.hook_stage in hook.stages
|
||||
]
|
||||
|
||||
if args.hook and not hooks:
|
||||
|
|
|
|||
|
|
@ -135,6 +135,9 @@ def _hook(*hook_dicts, **kwargs):
|
|||
if ret['language_version'] == C.DEFAULT:
|
||||
ret['language_version'] = languages[lang].get_default_version()
|
||||
|
||||
if not ret['stages']:
|
||||
ret['stages'] = root_config['default_stages']
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue