Handle merge conflicts as orchestration events
This commit is contained in:
@@ -184,3 +184,54 @@ test("run service creates, runs, and closes explicit sessions", async () => {
|
||||
code: "ENOENT",
|
||||
});
|
||||
});
|
||||
|
||||
test("run service marks session closed_with_conflicts when close merge conflicts", async () => {
|
||||
const workspaceRoot = await mkdtemp(resolve(tmpdir(), "ai-ops-run-service-close-conflict-"));
|
||||
const stateRoot = resolve(workspaceRoot, "state");
|
||||
const envPath = resolve(workspaceRoot, ".env");
|
||||
const projectPath = resolve(workspaceRoot, "project");
|
||||
|
||||
await mkdir(projectPath, { recursive: true });
|
||||
await execFileAsync("git", ["init", projectPath], { encoding: "utf8" });
|
||||
await execFileAsync("git", ["-C", projectPath, "config", "user.name", "AI Ops"], { encoding: "utf8" });
|
||||
await execFileAsync("git", ["-C", projectPath, "config", "user.email", "ai-ops@example.local"], { encoding: "utf8" });
|
||||
await writeFile(resolve(projectPath, "README.md"), "base\n", "utf8");
|
||||
await execFileAsync("git", ["-C", projectPath, "add", "README.md"], { encoding: "utf8" });
|
||||
await execFileAsync("git", ["-C", projectPath, "commit", "-m", "initial"], { encoding: "utf8" });
|
||||
|
||||
await writeFile(
|
||||
envPath,
|
||||
[
|
||||
`AGENT_STATE_ROOT=${stateRoot}`,
|
||||
"AGENT_WORKTREE_ROOT=.ai_ops/worktrees",
|
||||
"AGENT_WORKTREE_BASE_REF=HEAD",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const runService = new UiRunService({
|
||||
workspaceRoot,
|
||||
envFilePath: ".env",
|
||||
});
|
||||
|
||||
const createdSession = await runService.createSession({
|
||||
projectPath,
|
||||
});
|
||||
|
||||
await writeFile(resolve(createdSession.baseWorkspacePath, "README.md"), "base branch update\n", "utf8");
|
||||
await execFileAsync("git", ["-C", createdSession.baseWorkspacePath, "add", "README.md"], { encoding: "utf8" });
|
||||
await execFileAsync("git", ["-C", createdSession.baseWorkspacePath, "commit", "-m", "base update"], { encoding: "utf8" });
|
||||
|
||||
await writeFile(resolve(projectPath, "README.md"), "project branch update\n", "utf8");
|
||||
await execFileAsync("git", ["-C", projectPath, "add", "README.md"], { encoding: "utf8" });
|
||||
await execFileAsync("git", ["-C", projectPath, "commit", "-m", "project update"], { encoding: "utf8" });
|
||||
|
||||
const closed = await runService.closeSession({
|
||||
sessionId: createdSession.sessionId,
|
||||
mergeToProject: true,
|
||||
});
|
||||
|
||||
assert.equal(closed.sessionStatus, "closed_with_conflicts");
|
||||
const baseWorkspaceStats = await stat(createdSession.baseWorkspacePath);
|
||||
assert.equal(baseWorkspaceStats.isDirectory(), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user