@@ -47,18 +47,16 @@ def _print_user_skipped(hook, write, args):
4747 ))
4848
4949
50- def _run_single_hook (runner , repository , hook_id , args , write , skips = set ()):
50+ def _run_single_hook (runner , repository , hook , args , write , skips = set ()):
5151 if args .all_files :
5252 get_filenames = git .get_all_files_matching
5353 elif git .is_in_merge_conflict ():
5454 get_filenames = git .get_conflicted_files_matching
5555 else :
5656 get_filenames = git .get_staged_files_matching
5757
58- hook = repository .hooks [hook_id ]
59-
6058 filenames = get_filenames (hook ['files' ], hook ['exclude' ])
61- if hook_id in skips :
59+ if hook [ 'id' ] in skips :
6260 _print_user_skipped (hook , write , args )
6361 return 0
6462 elif not filenames :
@@ -70,9 +68,9 @@ def _run_single_hook(runner, repository, hook_id, args, write, skips=set()):
7068 write (get_hook_message (_hook_msg_start (hook , args .verbose ), end_len = 6 ))
7169 sys .stdout .flush ()
7270
73- retcode , stdout , stderr = repository .run_hook (hook_id , filenames )
71+ retcode , stdout , stderr = repository .run_hook (hook , filenames )
7472
75- if retcode != repository . hooks [ hook_id ] ['expected_return_value' ]:
73+ if retcode != hook ['expected_return_value' ]:
7674 retcode = 1
7775 print_color = color .RED
7876 pass_fail = 'Failed'
@@ -101,9 +99,9 @@ def _run_hooks(runner, args, write, environ):
10199 skips = _get_skips (environ )
102100
103101 for repo in runner .repositories :
104- for hook_id in repo .hooks :
102+ for _ , hook in repo .hooks :
105103 retval |= _run_single_hook (
106- runner , repo , hook_id , args , write , skips = skips ,
104+ runner , repo , hook , args , write , skips = skips ,
107105 )
108106
109107 return retval
@@ -112,8 +110,11 @@ def _run_hooks(runner, args, write, environ):
112110def _run_hook (runner , args , write ):
113111 hook_id = args .hook
114112 for repo in runner .repositories :
115- if hook_id in repo .hooks :
116- return _run_single_hook (runner , repo , hook_id , args , write = write )
113+ for hook_id_in_repo , hook in repo .hooks :
114+ if hook_id == hook_id_in_repo :
115+ return _run_single_hook (
116+ runner , repo , hook , args , write = write ,
117+ )
117118 else :
118119 write ('No hook with id `{0}`\n ' .format (hook_id ))
119120 return 1
0 commit comments