mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Do not run legacy script again when this is the one being executed
This commit is contained in:
parent
da00fa98f9
commit
cd61269389
1 changed files with 4 additions and 2 deletions
|
|
@ -54,8 +54,10 @@ def _run_legacy():
|
||||||
else:
|
else:
|
||||||
stdin = None
|
stdin = None
|
||||||
|
|
||||||
legacy_hook = os.path.join(HERE, '{}.legacy'.format(HOOK_TYPE))
|
legacy_script = HOOK_TYPE + '.legacy'
|
||||||
if os.access(legacy_hook, os.X_OK):
|
is_legacy_executed = os.path.basename(__file__) == legacy_script
|
||||||
|
legacy_hook = os.path.join(HERE, legacy_script)
|
||||||
|
if not is_legacy_executed and os.access(legacy_hook, os.X_OK):
|
||||||
cmd = _norm_exe(legacy_hook) + (legacy_hook,) + tuple(sys.argv[1:])
|
cmd = _norm_exe(legacy_hook) + (legacy_hook,) + tuple(sys.argv[1:])
|
||||||
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE if stdin else None)
|
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE if stdin else None)
|
||||||
proc.communicate(stdin)
|
proc.communicate(stdin)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue