fix: align apply-patch failure flow with codex
This commit is contained in:
@@ -26,11 +26,10 @@ export interface PatchUpdateResult {
|
||||
export interface ApplyPatchV2Outcome {
|
||||
hunk: number;
|
||||
action: PatchHunk["kind"] | "move";
|
||||
status: "applied" | "failed" | "pending";
|
||||
status: "applied" | "failed";
|
||||
path: string;
|
||||
targetPath?: string;
|
||||
change?: string;
|
||||
reason?: string;
|
||||
partialChanges?: string[];
|
||||
error?: {
|
||||
name?: string;
|
||||
@@ -296,18 +295,10 @@ async function applyPatchV2Hunks(executor: ApplyPatchV2Executor, hunks: PatchHun
|
||||
...(partialChanges.length > 0 ? { partialChanges } : {}),
|
||||
error: errorSummary(error),
|
||||
});
|
||||
for (let pendingIndex = index + 1; pendingIndex < hunks.length; pendingIndex += 1) {
|
||||
outcomes.push({
|
||||
...outcomeBase(hunks[pendingIndex] as PatchHunk, pendingIndex),
|
||||
status: "pending",
|
||||
reason: "skipped_after_previous_failure",
|
||||
});
|
||||
}
|
||||
throw new ApplyPatchV2Error(error instanceof Error ? error.message : String(error), {
|
||||
partialChanges: changed,
|
||||
outcomes,
|
||||
failed: outcomes.find((item) => item.status === "failed") ?? null,
|
||||
pending: outcomes.filter((item) => item.status === "pending"),
|
||||
cause: error instanceof ApplyPatchV2Error ? error.details : undefined,
|
||||
});
|
||||
}
|
||||
@@ -342,7 +333,6 @@ function formatApplyPatchFailure(error: unknown): string {
|
||||
lines.push("Patch status:");
|
||||
appendOutcomeSection(lines, "Applied before failure:", outcomes.filter((item) => item.status === "applied"));
|
||||
appendOutcomeSection(lines, "Failed:", outcomes.filter((item) => item.status === "failed"));
|
||||
appendOutcomeSection(lines, "Pending after failure:", outcomes.filter((item) => item.status === "pending"));
|
||||
}
|
||||
return `${lines.join("\n")}\n`;
|
||||
}
|
||||
@@ -359,7 +349,6 @@ function formatOutcome(outcome: ApplyPatchV2Outcome): string {
|
||||
const target = outcome.targetPath === undefined ? outcome.path : `${outcome.path} -> ${outcome.targetPath}`;
|
||||
const base = `hunk ${outcome.hunk} ${outcome.action} ${target}`;
|
||||
if (outcome.status === "applied") return outcome.change === undefined ? base : `${outcome.change} (${base})`;
|
||||
if (outcome.status === "pending") return `${base} (pending)`;
|
||||
const error = outcome.error?.message ?? "failed";
|
||||
const partial = outcome.partialChanges === undefined || outcome.partialChanges.length === 0
|
||||
? ""
|
||||
|
||||
Reference in New Issue
Block a user