From 1283c75cc86b9b1126e4713f178576b09b450b2d Mon Sep 17 00:00:00 2001 From: Robin Quintero Date: Fri, 22 Sep 2023 14:58:53 -0500 Subject: [PATCH] feat(build): #979 remove _add_safe_directory - remove _add_safe_directory function Signed-off-by: Robin Quintero --- .github/workflows/dev.yml | 3 +-- src/cli/main/cli.py | 34 ++-------------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 7911bcf42..5f156e503 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -48,8 +48,7 @@ jobs: - uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845 name: /deployTerraform/module with: - set-safe-directory: /github/workspace - args: sh -c "nix-env -if . && m . /deployTerraform/module" + args: sh -c "git config --global --add safe.directory /github/workspace && nix-env -if . && m . /deployTerraform/module" macos_deployTerraform_module: runs-on: macos-latest steps: diff --git a/src/cli/main/cli.py b/src/cli/main/cli.py index e2d9e8172..1698bbf11 100644 --- a/src/cli/main/cli.py +++ b/src/cli/main/cli.py @@ -120,13 +120,11 @@ def _clone_src(src: str) -> str: if abspath(src) == CWD: # `m .` ? if NIX_STABLE: - _add_safe_directory() _clone_src_git_worktree_add(src, head) else: # Nix with Flakes already ensures a pristine git repo head = src else: - _add_safe_directory() if ( (match := _clone_src_github(src)) or (match := _clone_src_gitlab(src)) @@ -149,20 +147,6 @@ def _clone_src(src: str) -> str: return head -def _add_safe_directory() -> None: - cmd = [ - "git", - "config", - "--global", - "--add", - "safe.directory", - "/github/workspace", - ] - out = _run(cmd, stderr=None, stdout=sys.stderr.fileno()) - if out != 0: - raise SystemExit(out) - - def _clone_src_git_init(head: str) -> None: cmd = ["git", "init", "--initial-branch=____", "--shared=false", head] out = _run(cmd, stderr=None, stdout=sys.stderr.fileno()) @@ -413,23 +397,9 @@ class Config(NamedTuple): def _get_named_temporary_file_name() -> str: - attempts = 0 file_name = "" - success = False - while attempts < 5 and not success: - try: - with tempfile.NamedTemporaryFile(delete=True) as file: - file_name = file.name - success = True - except FileExistsError as error: - CON.print( - f"Failed to create {error.filename}, retrying in 1 second..." - ) - attempts += 1 - sleep(1) - - if not success: - raise FileExistsError("Could not create file after 5 attempts.") + with tempfile.NamedTemporaryFile(delete=True) as file: + file_name = file.name return file_name