S604: fix

This commit is contained in:
Jörg Thalheim
2025-08-20 16:16:17 +02:00
parent 4b1ab4cdde
commit 1c24b4c6cb
2 changed files with 40 additions and 10 deletions

View File

@@ -441,14 +441,44 @@ def writable_clan_core(
# Copy all tracked and untracked files (excluding ignored) # Copy all tracked and untracked files (excluding ignored)
# Using git ls-files with -z for null-terminated output to handle filenames with spaces # Using git ls-files with -z for null-terminated output to handle filenames with spaces
sp.run(
f"(git ls-files -z; git ls-files -z --others --exclude-standard) | " # Get tracked files
f"xargs -0 cp --parents -t {temp_flake}/", tracked_files = (
shell=True, sp.run(
cwd=clan_core, ["git", "ls-files", "-z"],
check=True, cwd=clan_core,
capture_output=True,
text=True,
check=True,
)
.stdout.rstrip("\0")
.split("\0")
) )
# Get untracked files (excluding ignored)
untracked_files = (
sp.run(
["git", "ls-files", "-z", "--others", "--exclude-standard"],
cwd=clan_core,
capture_output=True,
text=True,
check=True,
)
.stdout.rstrip("\0")
.split("\0")
)
# Combine and filter out empty strings
all_files = [f for f in tracked_files + untracked_files if f]
# Copy files preserving directory structure
if all_files:
sp.run(
["cp", "--parents", "-t", str(temp_flake), "--", *all_files],
cwd=clan_core,
check=True,
)
# Copy .git directory to maintain git functionality # Copy .git directory to maintain git functionality
if (clan_core / ".git").is_dir(): if (clan_core / ".git").is_dir():
shutil.copytree( shutil.copytree(

View File

@@ -157,7 +157,7 @@ def test_run_environment(hosts: list[Remote], runtime: AsyncRuntime) -> None:
None, None,
host.run_local, host.run_local,
["echo $env_var"], ["echo $env_var"],
RunOpts(shell=True, log=Log.STDERR), RunOpts(shell=True, log=Log.STDERR), # noqa: S604
extra_env={"env_var": "true"}, extra_env={"env_var": "true"},
) )
assert proc.wait().result.stdout == "true\n" assert proc.wait().result.stdout == "true\n"
@@ -230,13 +230,13 @@ def test_run_exception(hosts: list[Remote], runtime: AsyncRuntime) -> None:
None, None,
host.run_local, host.run_local,
["exit 1"], ["exit 1"],
RunOpts(shell=True, check=False), RunOpts(shell=True, check=False), # noqa: S604
) )
assert proc.wait().result.returncode == 1 assert proc.wait().result.returncode == 1
try: try:
for host in hosts: for host in hosts:
runtime.async_run(None, host.run_local, ["exit 1"], RunOpts(shell=True)) runtime.async_run(None, host.run_local, ["exit 1"], RunOpts(shell=True)) # noqa: S604
runtime.join_all() runtime.join_all()
runtime.check_all() runtime.check_all()
except Exception: except Exception:
@@ -248,7 +248,7 @@ def test_run_exception(hosts: list[Remote], runtime: AsyncRuntime) -> None:
def test_run_function_exception(hosts: list[Remote], runtime: AsyncRuntime) -> None: def test_run_function_exception(hosts: list[Remote], runtime: AsyncRuntime) -> None:
def some_func(h: Remote) -> CmdOut: def some_func(h: Remote) -> CmdOut:
return h.run_local(["exit 1"], RunOpts(shell=True)) return h.run_local(["exit 1"], RunOpts(shell=True)) # noqa: S604
try: try:
for host in hosts: for host in hosts: