mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-17 22:40:11 -06:00
Filtering of hooks for commit or push stages
This commit is contained in:
@@ -20,10 +20,11 @@ PREVIOUS_IDENTIFYING_HASHES = (
|
||||
'4d9958c90bc262f47553e2c073f14cfe',
|
||||
'd8ee923c46731b42cd95cc869add4062',
|
||||
'49fd668cb42069aa1b6048464be5d395',
|
||||
'79f09a650522a87b0da915d0d983b2de'
|
||||
)
|
||||
|
||||
|
||||
IDENTIFYING_HASH = '79f09a650522a87b0da915d0d983b2de'
|
||||
IDENTIFYING_HASH = 'e358c9dae00eac5d06b38dfdb1e33a8c'
|
||||
|
||||
|
||||
def is_our_pre_commit(filename):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user