fix: commit agent changes before opening PR
This commit is contained in:
@@ -136,6 +136,10 @@ class FakeWorkspaceManager:
|
||||
def push_branch(self, workspace, branch_name):
|
||||
self.pushed.append(branch_name)
|
||||
|
||||
def commit_changes(self, workspace, message):
|
||||
self.commit_message = message
|
||||
return "abc1234"
|
||||
|
||||
def cleanup(self, workspace):
|
||||
pass
|
||||
|
||||
@@ -150,12 +154,16 @@ class FakeRunner:
|
||||
if role == self.fail_role:
|
||||
return AgentResult(exit_code=1, stdout="", stderr="failed")
|
||||
if role == "implementer":
|
||||
(Path(cwd) / "AGENT_IMPLEMENTATION_REPORT.md").write_text(
|
||||
output_dir = Path(cwd) / ".agent-output"
|
||||
output_dir.mkdir(exist_ok=True)
|
||||
(output_dir / "AGENT_IMPLEMENTATION_REPORT.md").write_text(
|
||||
"## Summary\nImplemented\n\n## Test commands run\npytest\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
if role == "reviewer":
|
||||
(Path(cwd) / "AGENT_REVIEW_REPORT.md").write_text(
|
||||
output_dir = Path(cwd) / ".agent-output"
|
||||
output_dir.mkdir(exist_ok=True)
|
||||
(output_dir / "AGENT_REVIEW_REPORT.md").write_text(
|
||||
"## Verdict\nAPPROVE\n\n## Suggested PR Comment\nLooks good.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
@@ -196,11 +204,12 @@ def test_run_task_success_posts_review_comments(db, tmp_path):
|
||||
return httpx.Response(201, json={"id": 1})
|
||||
return httpx.Response(404)
|
||||
|
||||
workspace_manager = FakeWorkspaceManager(tmp_path / "work")
|
||||
task = TaskRunner(
|
||||
db=db,
|
||||
config=config,
|
||||
gitea=make_client(handler),
|
||||
workspace_manager=FakeWorkspaceManager(tmp_path / "work"),
|
||||
workspace_manager=workspace_manager,
|
||||
command_runner=FakeRunner(),
|
||||
worker_id="worker",
|
||||
).run_once()
|
||||
@@ -208,6 +217,11 @@ def test_run_task_success_posts_review_comments(db, tmp_path):
|
||||
assert task is not None
|
||||
assert task.state == TaskState.HUMAN_REVIEW_READY
|
||||
assert task.pr_number == 5
|
||||
assert workspace_manager.pushed == ["agent/issue-1-ready-issue"]
|
||||
assert workspace_manager.commit_message == "agent: implement issue #1 - Ready issue"
|
||||
pull_requests = [payload for _, path, payload in requests if path == "/api/v1/repos/acme/service/pulls"]
|
||||
assert pull_requests[0]["title"] == "代理实现:Ready issue"
|
||||
assert "代理实现报告" in pull_requests[0]["body"]
|
||||
command = json.loads(db.list_agent_runs(task.id)[0]["command_json"])
|
||||
assert command[1] == "--cd"
|
||||
assert Path(command[2]).is_absolute()
|
||||
|
||||
@@ -38,9 +38,9 @@ def test_prompt_and_pr_body_include_contract_sections(db):
|
||||
prompt = render_implementer_prompt(repo, issue, "agent/issue-7-add-thing")
|
||||
body = render_pr_body(issue, "## Summary\nDone")
|
||||
|
||||
assert "AGENT_IMPLEMENTATION_REPORT.md" in prompt
|
||||
assert "Closes #7" in body
|
||||
assert "Human Review Gate" in body
|
||||
assert ".agent-output/AGENT_IMPLEMENTATION_REPORT.md" in prompt
|
||||
assert "关联 Issue:#7" in body
|
||||
assert "人工审核" in body
|
||||
|
||||
|
||||
def test_review_report_parsing_extracts_verdict_and_comment():
|
||||
|
||||
Reference in New Issue
Block a user