mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 01:51:46 +04:00
copy rust's pattern for conditional env
This commit is contained in:
parent
f2837cf5b2
commit
9a04b3967a
1 changed files with 8 additions and 11 deletions
|
|
@ -5,14 +5,11 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from pre_commit import lang_base
|
from pre_commit import lang_base
|
||||||
from pre_commit.envcontext import _Unset
|
|
||||||
from pre_commit.envcontext import envcontext
|
from pre_commit.envcontext import envcontext
|
||||||
from pre_commit.envcontext import PatchesT
|
from pre_commit.envcontext import PatchesT
|
||||||
from pre_commit.envcontext import UNSET
|
from pre_commit.envcontext import UNSET
|
||||||
from pre_commit.envcontext import Var
|
|
||||||
from pre_commit.prefix import Prefix
|
from pre_commit.prefix import Prefix
|
||||||
from pre_commit.util import cmd_output_b
|
from pre_commit.util import cmd_output_b
|
||||||
|
|
||||||
|
|
@ -49,17 +46,17 @@ def run_hook(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
PatchEntry = tuple[str, Union[str, _Unset, tuple[Union[str, Var], ...]]]
|
|
||||||
|
|
||||||
|
|
||||||
def get_env_patch(target_dir: str, version: str) -> PatchesT:
|
def get_env_patch(target_dir: str, version: str) -> PatchesT:
|
||||||
patches: list[PatchEntry] = [
|
patches = (
|
||||||
('JULIA_LOAD_PATH', target_dir),
|
('JULIA_LOAD_PATH', target_dir),
|
||||||
('JULIA_PROJECT', UNSET),
|
('JULIA_PROJECT', UNSET),
|
||||||
]
|
# Only set JULIAUP_CHANNEL if we don't want use the system's default
|
||||||
if version not in ('system', 'default'):
|
*(
|
||||||
patches.append(('JULIAUP_CHANNEL', version))
|
(('JULIAUP_CHANNEL', version),)
|
||||||
return tuple(patches)
|
if version not in ('system', 'default') else ()
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return patches
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue