mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Filtering of hooks for commit or push stages
This commit is contained in:
parent
e3a22061c5
commit
dd73ffd02f
8 changed files with 89 additions and 3 deletions
|
|
@ -175,6 +175,7 @@ def run(runner, args, write=sys_stdout_write_wrapper, environ=os.environ):
|
|||
|
||||
with ctx:
|
||||
repo_hooks = list(get_repo_hooks(runner))
|
||||
|
||||
if args.hook:
|
||||
repo_hooks = [
|
||||
(repo, hook) for repo, hook in repo_hooks
|
||||
|
|
@ -183,4 +184,11 @@ def run(runner, args, write=sys_stdout_write_wrapper, environ=os.environ):
|
|||
if not repo_hooks:
|
||||
write('No hook with id `{0}`\n'.format(args.hook))
|
||||
return 1
|
||||
|
||||
# Filter hooks for stages
|
||||
repo_hooks = [
|
||||
(repo, hook) for repo, hook in repo_hooks
|
||||
if not hook['stages'] or args.hook_stage in hook['stages']
|
||||
]
|
||||
|
||||
return _run_hooks(repo_hooks, args, write, environ)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue