pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pre-commit/pre-commit/commit/2a51ffcb81f6c8ed2e6467913c3343a8800f3ab9

f="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> Merge pull request #3662 from pre-commit/hook-impl-optional-hook-dir · pre-commit/pre-commit@2a51ffc · GitHub
Skip to content

Commit 2a51ffc

Browse files
authored
Merge pull request #3662 from pre-commit/hook-impl-optional-hook-dir
make --hook-dir optional for hook-impl
2 parents 965aeb1 + d7dee32 commit 2a51ffc

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

pre_commit/commands/hook_impl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
def _run_legacy(
1818
hook_type: str,
19-
hook_dir: str,
19+
hook_dir: str | None,
2020
args: Sequence[str],
2121
) -> tuple[int, bytes]:
2222
if os.environ.get('PRE_COMMIT_RUNNING_LEGACY'):
@@ -33,6 +33,9 @@ def _run_legacy(
3333
else:
3434
stdin = b''
3535

36+
if hook_dir is None: # git 2.54+ hooks
37+
return 0, stdin
38+
3639
# not running in legacy mode
3740
legacy_hook = os.path.join(hook_dir, f'{hook_type}.legacy')
3841
if not os.access(legacy_hook, os.X_OK):
@@ -259,7 +262,7 @@ def hook_impl(
259262
config: str,
260263
color: bool,
261264
hook_type: str,
262-
hook_dir: str,
265+
hook_dir: str | None,
263266
skip_on_missing_config: bool,
264267
args: Sequence[str],
265268
) -> int:

tests/commands/hook_impl_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ def test_run_legacy_does_not_exist(tmpdir):
6363
assert (retv, stdin) == (0, b'')
6464

6565

66+
def test_run_legacy_git_2_54():
67+
retv, stdin = hook_impl._run_legacy('pre-commit', None, ())
68+
assert (retv, stdin) == (0, b'')
69+
70+
6671
def test_run_legacy_executes_legacy_script(tmpdir, capfd):
6772
hook = tmpdir.join('pre-commit.legacy')
6873
hook.write('#!/usr/bin/env bash\necho hi "$@"\nexit 1\n')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy