Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bbc3130

Browse files
committed
Produce slightly more helpful message
1 parent ec72cb7 commit bbc3130

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

pre_commit/resources/hook-tmpl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,22 @@ def _norm_exe(exe):
4949

5050

5151
def _run_legacy():
52+
if __file__.endswith('.legacy'):
53+
raise SystemExit(
54+
"bug: pre-commit's script is installed in migration mode\n"
55+
'run `pre-commit install -f --hook-type {}` to fix this\n\n'
56+
'Please report this bug at '
57+
'https://github.com/pre-commit/pre-commit/issues'.format(
58+
HOOK_TYPE,
59+
),
60+
)
61+
5262
if HOOK_TYPE == 'pre-push':
5363
stdin = getattr(sys.stdin, 'buffer', sys.stdin).read()
5464
else:
5565
stdin = None
5666

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-
assert not is_legacy_executed, __file__
67+
legacy_hook = os.path.join(HERE, '{}.legacy'.format(HOOK_TYPE))
6168
if os.access(legacy_hook, os.X_OK):
6269
cmd = _norm_exe(legacy_hook) + (legacy_hook,) + tuple(sys.argv[1:])
6370
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE if stdin else None)

0 commit comments

Comments
 (0)