summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages/perl.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-30 16:53:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-30 16:53:19 +0000
commit02d5100afa71d1343de4066b812cd4cdc774d812 (patch)
tree6bccae957398fab29aaa226fb0bd65f0c258a36a /pre_commit/languages/perl.py
parentAdding upstream version 2.21.0. (diff)
downloadpre-commit-02d5100afa71d1343de4066b812cd4cdc774d812.tar.xz
pre-commit-02d5100afa71d1343de4066b812cd4cdc774d812.zip
Adding upstream version 3.0.2.upstream/3.0.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/languages/perl.py')
-rw-r--r--pre_commit/languages/perl.py34
1 files changed, 8 insertions, 26 deletions
diff --git a/pre_commit/languages/perl.py b/pre_commit/languages/perl.py
index 78bd65a..2530c0e 100644
--- a/pre_commit/languages/perl.py
+++ b/pre_commit/languages/perl.py
@@ -9,19 +9,13 @@ from typing import Sequence
from pre_commit.envcontext import envcontext
from pre_commit.envcontext import PatchesT
from pre_commit.envcontext import Var
-from pre_commit.hook import Hook
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
-from pre_commit.util import clean_path_on_failure
ENVIRONMENT_DIR = 'perl_env'
get_default_version = helpers.basic_get_default_version
health_check = helpers.basic_health_check
-
-
-def _envdir(prefix: Prefix, version: str) -> str:
- directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
- return prefix.path(directory)
+run_hook = helpers.basic_run_hook
def get_env_patch(venv: str) -> PatchesT:
@@ -39,11 +33,9 @@ def get_env_patch(venv: str) -> PatchesT:
@contextlib.contextmanager
-def in_env(
- prefix: Prefix,
- language_version: str,
-) -> Generator[None, None, None]:
- with envcontext(get_env_patch(_envdir(prefix, language_version))):
+def in_env(prefix: Prefix, version: str) -> Generator[None, None, None]:
+ envdir = helpers.environment_dir(prefix, ENVIRONMENT_DIR, version)
+ with envcontext(get_env_patch(envdir)):
yield
@@ -52,17 +44,7 @@ def install_environment(
) -> None:
helpers.assert_version_default('perl', version)
- with clean_path_on_failure(_envdir(prefix, version)):
- with in_env(prefix, version):
- helpers.run_setup_cmd(
- prefix, ('cpan', '-T', '.', *additional_dependencies),
- )
-
-
-def run_hook(
- hook: Hook,
- file_args: Sequence[str],
- color: bool,
-) -> tuple[int, bytes]:
- with in_env(hook.prefix, hook.language_version):
- return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
+ with in_env(prefix, version):
+ helpers.run_setup_cmd(
+ prefix, ('cpan', '-T', '.', *additional_dependencies),
+ )