Skip to content

Commit cd61269

Browse files
author
Tristan Carel
committed
Do not run legacy script again when this is the one being executed
1 parent da00fa9 commit cd61269

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎pre_commit/resources/hook-tmpl‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ def _run_legacy():
5454
else:
5555
stdin = None
5656

57-
legacy_hook = os.path.join(HERE, '{}.legacy'.format(HOOK_TYPE))
58-
if os.access(legacy_hook, os.X_OK):
57+
legacy_script = HOOK_TYPE + '.legacy'
58+
is_legacy_executed = os.path.basename(__file__) == legacy_script
59+
legacy_hook = os.path.join(HERE, legacy_script)
60+
if not is_legacy_executed and os.access(legacy_hook, os.X_OK):
5961
cmd = _norm_exe(legacy_hook) + (legacy_hook,) + tuple(sys.argv[1:])
6062
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE if stdin else None)
6163
proc.communicate(stdin)

0 commit comments

Comments
 (0)