test(issue-21): L13 compares against the pre-change diff_collect only when git history is available

The byte-identity check of the two-argument form read the old script with
`git show 25f4be3:...`, which fails in a `git archive` export (no .git) and
failed the test there. The comparison now runs only when the old script can
be read; the two-argument path is otherwise still covered by
test_b7_diff_untracked. L13 passes in the repository and in an export.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017R3Eg7MEpSWnm1oB9ZPP6G
This commit is contained in:
GodopuandClaude Opus 5 committed 2026-09-14 21:31:18 +00:00
1 parent 371099a82c
commit e6d2168a13
1 file changed
+7 -5
+7 -5
View File
@@ -332,12 +332,14 @@ def test_l13_snapshot_diff_is_commit_to_commit(wt_repo, monkeypatch, tmp_path):
# the two-argument form is unchanged: same output as the script before this change
old = subprocess.run(["git", "-C", str(SKILLS.parent.parent), "show", "25f4be3:.agents/skills/multi-agent-mux-loop/scripts/diff_collect.sh"],
capture_output=True, text=True)
old_sh = tmp_path / "diff_collect_old.sh"
old_sh.write_text(old.stdout)
new2 = _diff_collect(wt, base)
old2 = subprocess.run(["bash", "-c", f"source '{old_sh}' && mam_collect_changes_diff '{wt}' '{base}'"],
capture_output=True, text=True)
assert (new2.returncode, new2.stdout) == (old2.returncode, old2.stdout)
assert new2.returncode == 0 and "+modified" in new2.stdout and "+untracked" in new2.stdout
if old.returncode == 0 and old.stdout: # needs git history (absent in a `git archive` export)
old_sh = tmp_path / "diff_collect_old.sh"
old_sh.write_text(old.stdout)
old2 = subprocess.run(["bash", "-c", f"source '{old_sh}' && mam_collect_changes_diff '{wt}' '{base}'"],
capture_output=True, text=True)
assert (new2.returncode, new2.stdout) == (old2.returncode, old2.stdout)
def test_l13b_prompt_diff_comes_from_the_snapshot(wt_repo, monkeypatch, tmp_path):