mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Run only the specified hook even when stages exist in config.
This branches fixes the run logic so that when `pre-commit run some_hook -a` runs when the config contains `stages: ['commit']` for some other hook, only the hook specified as an argument will run. Fixes #772
This commit is contained in:
parent
f2da2c435c
commit
4640dc7b4a
2 changed files with 38 additions and 5 deletions
|
|
@ -254,11 +254,13 @@ def run(runner, store, args, environ=os.environ):
|
|||
repo_hooks = []
|
||||
for repo in repositories(runner.config, store):
|
||||
for _, hook in repo.hooks:
|
||||
if (
|
||||
(not args.hook or hook['id'] == args.hook) and
|
||||
not hook['stages'] or args.hook_stage in hook['stages']
|
||||
):
|
||||
repo_hooks.append((repo, hook))
|
||||
if args.hook:
|
||||
if args.hook == hook['id']:
|
||||
repo_hooks.append((repo, hook))
|
||||
break
|
||||
else:
|
||||
if not hook['stages'] or args.hook_stage in hook['stages']:
|
||||
repo_hooks.append((repo, hook))
|
||||
|
||||
if args.hook and not repo_hooks:
|
||||
output.write_line('No hook with id `{}`'.format(args.hook))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue