From 1c24b4c6cb8ea6b534cd2314bd08dbb6cbd6e5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 20 Aug 2025 16:16:17 +0200 Subject: [PATCH] S604: fix --- .../clan_cli/tests/fixtures_flakes.py | 42 ++++++++++++++++--- pkgs/clan-cli/clan_lib/ssh/remote_test.py | 8 ++-- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py b/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py index 9f15a4b94..c34b01b10 100644 --- a/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py +++ b/pkgs/clan-cli/clan_cli/tests/fixtures_flakes.py @@ -441,14 +441,44 @@ 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 - sp.run( - f"(git ls-files -z; git ls-files -z --others --exclude-standard) | " - f"xargs -0 cp --parents -t {temp_flake}/", - shell=True, - cwd=clan_core, - check=True, + + # Get tracked files + tracked_files = ( + sp.run( + ["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, + ) + # Copy .git directory to maintain git functionality if (clan_core / ".git").is_dir(): shutil.copytree( diff --git a/pkgs/clan-cli/clan_lib/ssh/remote_test.py b/pkgs/clan-cli/clan_lib/ssh/remote_test.py index 40d93205b..9c4ec3f54 100644 --- a/pkgs/clan-cli/clan_lib/ssh/remote_test.py +++ b/pkgs/clan-cli/clan_lib/ssh/remote_test.py @@ -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: