mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Produce slightly more helpful message
This commit is contained in:
parent
ec72cb7260
commit
bbc3130af2
1 changed files with 11 additions and 4 deletions
|
|
@ -49,15 +49,22 @@ def _norm_exe(exe):
|
||||||
|
|
||||||
|
|
||||||
def _run_legacy():
|
def _run_legacy():
|
||||||
|
if __file__.endswith('.legacy'):
|
||||||
|
raise SystemExit(
|
||||||
|
"bug: pre-commit's script is installed in migration mode\n"
|
||||||
|
'run `pre-commit install -f --hook-type {}` to fix this\n\n'
|
||||||
|
'Please report this bug at '
|
||||||
|
'https://github.com/pre-commit/pre-commit/issues'.format(
|
||||||
|
HOOK_TYPE,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
if HOOK_TYPE == 'pre-push':
|
if HOOK_TYPE == 'pre-push':
|
||||||
stdin = getattr(sys.stdin, 'buffer', sys.stdin).read()
|
stdin = getattr(sys.stdin, 'buffer', sys.stdin).read()
|
||||||
else:
|
else:
|
||||||
stdin = None
|
stdin = None
|
||||||
|
|
||||||
legacy_script = HOOK_TYPE + '.legacy'
|
legacy_hook = os.path.join(HERE, '{}.legacy'.format(HOOK_TYPE))
|
||||||
is_legacy_executed = os.path.basename(__file__) == legacy_script
|
|
||||||
legacy_hook = os.path.join(HERE, legacy_script)
|
|
||||||
assert not is_legacy_executed, __file__
|
|
||||||
if os.access(legacy_hook, os.X_OK):
|
if 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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue