Preserve discarded patch context
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-08-28 13:55:39 +02:00
parent 0f2f131034
commit 34bf645957
4 changed files with 36 additions and 2 deletions

View File

@@ -115,6 +115,13 @@ class GitWorkspace:
deleted += int(remove) if remove.isdigit() else 0
return ChangeSummary(tuple(files), added, deleted)
def diff(self, limit: int = 12_000) -> str:
output = self._git("diff", "--no-ext-diff", "--unified=3").stdout
if len(output) <= limit:
return output
half = limit // 2
return output[:half] + "\n...[diff middle omitted]...\n" + output[-half:]
def commit(self, report_id: int) -> str:
self._git("add", "--all")
self._git("commit", "-m", f"Fix failure report #{report_id}")

View File

@@ -120,6 +120,7 @@ class AutomationWorker:
report.id,
attempt,
)
discarded_diff = workspace.diff()
workspace.restore_checkpoint(valid_checkpoint)
restored_state = (
"The last syntax-valid changes were restored. Correct them without recreating "
@@ -131,7 +132,8 @@ class AutomationWorker:
report,
RuntimeError(
f"{exception}\n{restored_state} Make smaller edits and run php -l on each "
"changed PHP file."
"changed PHP file. Reconstruct the intended application fix from this discarded "
f"patch excerpt, correcting its syntax:\n{discarded_diff}"
),
)
continue