Implement default_stages

This commit is contained in:
Anthony Sottile 2019-01-06 09:54:55 -08:00
parent 9c6a1d80d6
commit bd65d8947f
4 changed files with 29 additions and 3 deletions

View file

@ -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),
)

View file

@ -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:

View file

@ -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