Preserve valid agent retry progress
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-08-28 13:15:15 +02:00
parent 441c598890
commit aa979f3ca9
4 changed files with 101 additions and 5 deletions

View File

@@ -53,4 +53,34 @@ def test_discard_changes_restores_clean_disposable_workspace(tmp_path) -> None:
workspace.discard_changes()
assert tracked.read_text() == "<?php\nreturn [];\n"
assert not untracked.exists()
assert not untracked.exists()
def test_checkpoint_restores_last_valid_changes(tmp_path) -> None:
workspace = GitWorkspace(settings(workspace_root=tmp_path), 4)
workspace.path.mkdir()
subprocess.run(["git", "init"], cwd=workspace.path, check=True, capture_output=True)
subprocess.run(
["git", "config", "user.email", "test@example.invalid"],
cwd=workspace.path,
check=True,
)
subprocess.run(
["git", "config", "user.name", "Test"],
cwd=workspace.path,
check=True,
)
tracked = workspace.path / "config.php"
tracked.write_text("<?php\nreturn [];\n")
subprocess.run(["git", "add", "."], cwd=workspace.path, check=True)
subprocess.run(["git", "commit", "-m", "base"], cwd=workspace.path, check=True, capture_output=True)
tracked.write_text("<?php\nreturn ['valid'];\n")
added = workspace.path / "test.php"
added.write_text("<?php\n")
checkpoint = workspace.checkpoint()
tracked.write_text("<?php\nreturn [broken;\n")
workspace.restore_checkpoint(checkpoint)
assert tracked.read_text() == "<?php\nreturn ['valid'];\n"
assert added.exists()