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,10 +441,40 @@ def writable_clan_core(
# Copy all tracked and untracked files (excluding ignored)
# Using git ls-files with -z for null-terminated output to handle filenames with spaces
# Get tracked files
tracked_files = (
sp.run(
f"(git ls-files -z; git ls-files -z --others --exclude-standard) | "
f"xargs -0 cp --parents -t {temp_flake}/",
shell=True,
["git", "ls-files", "-z"],
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,
)

View File

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