Skip to content

Commit

Permalink
feat(build): fluidattacks#979 remove _add_safe_directory
Browse files Browse the repository at this point in the history
- remove _add_safe_directory function

Signed-off-by: Robin Quintero <rohaquinlop301@gmail.com>
  • Loading branch information
rohaquinlop committed Sep 22, 2023
1 parent ad02da4 commit c65bfbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "chown -R root:root /github/workspace && nix-env -if . && m . /deployTerraform/module"
macos_deployTerraform_module:
runs-on: macos-latest
steps:
Expand Down
34 changes: 2 additions & 32 deletions src/cli/main/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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())
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit c65bfbb

Please sign in to comment.