mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-15 13:30:17 -06:00
fix r local hooks
`language: r` acts more like `language: script` so we have to *not* append the prefix when run with `repo: local`
This commit is contained in:
@@ -66,6 +66,7 @@ class Language(Protocol):
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]:
|
||||
|
||||
@@ -127,6 +127,7 @@ def run_hook(
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]: # pragma: win32 no cover
|
||||
|
||||
@@ -19,6 +19,7 @@ def run_hook(
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]: # pragma: win32 no cover
|
||||
|
||||
@@ -18,6 +18,7 @@ def run_hook(
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]:
|
||||
|
||||
@@ -146,6 +146,7 @@ def basic_run_hook(
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]:
|
||||
|
||||
@@ -93,6 +93,7 @@ def run_hook(
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]:
|
||||
|
||||
@@ -35,8 +35,13 @@ def in_env(prefix: Prefix, version: str) -> Generator[None, None, None]:
|
||||
yield
|
||||
|
||||
|
||||
def _prefix_if_file_entry(entry: list[str], prefix: Prefix) -> Sequence[str]:
|
||||
if entry[1] == '-e':
|
||||
def _prefix_if_file_entry(
|
||||
entry: list[str],
|
||||
prefix: Prefix,
|
||||
*,
|
||||
is_local: bool,
|
||||
) -> Sequence[str]:
|
||||
if entry[1] == '-e' or is_local:
|
||||
return entry[1:]
|
||||
else:
|
||||
return (prefix.path(entry[1]),)
|
||||
@@ -73,11 +78,14 @@ def _cmd_from_hook(
|
||||
prefix: Prefix,
|
||||
entry: str,
|
||||
args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
) -> tuple[str, ...]:
|
||||
cmd = shlex.split(entry)
|
||||
_entry_validate(cmd)
|
||||
|
||||
return (cmd[0], *RSCRIPT_OPTS, *_prefix_if_file_entry(cmd, prefix), *args)
|
||||
cmd_part = _prefix_if_file_entry(cmd, prefix, is_local=is_local)
|
||||
return (cmd[0], *RSCRIPT_OPTS, *cmd_part, *args)
|
||||
|
||||
|
||||
def install_environment(
|
||||
@@ -153,10 +161,11 @@ def run_hook(
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]:
|
||||
cmd = _cmd_from_hook(prefix, entry, args)
|
||||
cmd = _cmd_from_hook(prefix, entry, args, is_local=is_local)
|
||||
return helpers.run_xargs(
|
||||
cmd,
|
||||
file_args,
|
||||
|
||||
@@ -18,6 +18,7 @@ def run_hook(
|
||||
args: Sequence[str],
|
||||
file_args: Sequence[str],
|
||||
*,
|
||||
is_local: bool,
|
||||
require_serial: bool,
|
||||
color: bool,
|
||||
) -> tuple[int, bytes]:
|
||||
|
||||
Reference in New Issue
Block a user