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 8e5b6cc commit c2a22fb
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/cli/main/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import tempfile
import textwrap
from time import (
sleep,
time,
)
from tui import (
Expand Down Expand Up @@ -119,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 @@ -148,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 @@ -411,11 +396,19 @@ class Config(NamedTuple):
cache: List[Dict[str, str]]


def _get_named_temporary_file_name() -> str:
file_name = ""
with tempfile.NamedTemporaryFile(delete=True) as file:
file_name = file.name
return file_name


def _get_config(head: str, attr_paths: str) -> Config:
CON.out()
CON.rule("Building project configuration")
CON.out()
out: str = tempfile.mktemp() # nosec

out: str = _get_named_temporary_file_name()
code = _run(
args=_nix_build(
attr="config.configAsJson"
Expand Down

0 comments on commit c2a22fb

Please sign in to comment.