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:
Anthony Sottile
2023-01-29 17:27:42 -05:00
parent 6eacdd440e
commit 420902f67c
12 changed files with 51 additions and 6 deletions

View File

@@ -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]:

View File

@@ -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

View File

@@ -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

View File

@@ -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]:

View File

@@ -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]:

View File

@@ -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]:

View File

@@ -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,

View File

@@ -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]: