This commit is contained in:
@@ -94,6 +94,15 @@ class GitWorkspace:
|
||||
self._git("reset", "--hard", "HEAD")
|
||||
self._git("clean", "-fd")
|
||||
|
||||
def checkpoint(self) -> str:
|
||||
self._git("add", "--all")
|
||||
return self._git("stash", "create").stdout.strip()
|
||||
|
||||
def restore_checkpoint(self, checkpoint: str | None) -> None:
|
||||
self.discard_changes()
|
||||
if checkpoint:
|
||||
self._git("stash", "apply", checkpoint)
|
||||
|
||||
def summary(self) -> ChangeSummary:
|
||||
self._git("add", "-N", "--all")
|
||||
output = self._git("diff", "--numstat").stdout
|
||||
|
||||
@@ -55,6 +55,7 @@ class AutomationWorker:
|
||||
LOG.info("Report %s branch=%s workspace ready", report.id, workspace.branch)
|
||||
task = build_task(report)
|
||||
metadata["agent_output"] = []
|
||||
valid_checkpoint: str | None = None
|
||||
for attempt in range(1, self.settings.max_agent_attempts + 1):
|
||||
LOG.info(
|
||||
"Report %s agent attempt %s/%s starting",
|
||||
@@ -108,15 +109,22 @@ class AutomationWorker:
|
||||
report.id,
|
||||
attempt,
|
||||
)
|
||||
workspace.discard_changes()
|
||||
workspace.restore_checkpoint(valid_checkpoint)
|
||||
restored_state = (
|
||||
"The last syntax-valid changes were restored. Correct them without recreating "
|
||||
"the malformed edit."
|
||||
if valid_checkpoint
|
||||
else "The malformed attempt was discarded. Start again from the clean repository."
|
||||
)
|
||||
task = build_retry_task(
|
||||
report,
|
||||
RuntimeError(
|
||||
f"{exception}\nThe malformed attempt was discarded. Start again from the clean "
|
||||
"repository, make smaller edits, and run php -l on each changed PHP file."
|
||||
f"{exception}\n{restored_state} Make smaller edits and run php -l on each "
|
||||
"changed PHP file."
|
||||
),
|
||||
)
|
||||
continue
|
||||
valid_checkpoint = workspace.checkpoint()
|
||||
try:
|
||||
metadata["tests"] = self._run_tests(workspace, report.id, attempt)
|
||||
LOG.info("Report %s attempt %s validation passed", report.id, attempt)
|
||||
|
||||
Reference in New Issue
Block a user