From db3eb052a6b0288535591f1155a2f6c2efe3a4cb Mon Sep 17 00:00:00 2001 From: Mikhail Petrov Date: Thu, 2 Jul 2026 16:42:02 +0300 Subject: [PATCH] fix: stop mutating-git-command test false-positiving on pytest tmp paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_prepare_detached_review_never_calls_mutating_git_commands checked mutating-command tokens (checkout, stash, reset, restore, commit, rm) against a joined-argv string, so the check false-positives whenever an unrelated argument substring matches — e.g. a random pytest tmp_path component containing "rm" (observed on macOS CI: ".../cx43xdqhzy2rmp6tqr..."). Check individual argv tokens instead of a joined string. --- tests/test_map_step_runner.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_map_step_runner.py b/tests/test_map_step_runner.py index 40e85c7f..a589a1a4 100644 --- a/tests/test_map_step_runner.py +++ b/tests/test_map_step_runner.py @@ -8111,11 +8111,13 @@ def mock_run(cmd: list[str], **kwargs: object) -> real_subprocess.CompletedProce # "worktree add" is the one permitted mutation (creates a new worktree entry). # All other staging/checkout/destructive git subcommands must never appear. + # Check individual argv tokens, not a joined string — a joined-string substring + # check false-positives when an unrelated argument (e.g. a pytest tmp_path + # component) happens to contain "rm" or another mutating-command substring. mutating = ("checkout", "stash", "reset", "restore", "commit", "rm") for call in recorded_calls: - joined = " ".join(call) for bad in mutating: - assert bad not in joined, ( + assert bad not in call, ( f"mutating git command {bad!r} found in call: {call}" ) # bare "git add " (staging) must not appear; "worktree add" is fine