fix: scope conflict confirmation to agent changes
This commit is contained in:
1 parent
54fc6ee494
commit
eb67012e82
2 files changed
+29
-1
No files matched your search
@@ -219,7 +219,7 @@ export async function resolvePullRequestConflicts(
|
||||
|
||||
const finalDiff = await runCommand(
|
||||
"git",
|
||||
["diff", "--cached", "--no-ext-diff", "--unified=80"],
|
||||
buildConflictReviewDiffArgs(agentChanges),
|
||||
worktree,
|
||||
gitEnv
|
||||
);
|
||||
@@ -343,6 +343,16 @@ export function buildConflictPushArgs(params: {
|
||||
];
|
||||
}
|
||||
|
||||
export function buildConflictReviewDiffArgs(changedFiles: string[]): string[] {
|
||||
if (changedFiles.length === 0) {
|
||||
throw new Error("Conflict review requires at least one agent-changed file.");
|
||||
}
|
||||
for (const file of changedFiles) {
|
||||
validateAgentChangePath(file);
|
||||
}
|
||||
return ["diff", "--cached", "--no-ext-diff", "--unified=80", "--", ...changedFiles];
|
||||
}
|
||||
|
||||
export function describeConflictResolutionFailure(error: unknown): string {
|
||||
const message = error instanceof Error ? error.message.toLowerCase() : "";
|
||||
if (message.includes("refusing to merge unrelated histories") || message.includes("shallow")) {
|
||||
@@ -373,6 +383,9 @@ export function describeConflictResolutionFailure(error: unknown): string {
|
||||
if (message.includes("git diff --check failed")) {
|
||||
return "The candidate resolution still contained Git whitespace or conflict-marker errors after one automatic correction pass. No commit was pushed.";
|
||||
}
|
||||
if (message.includes("resolved staged diff contains")) {
|
||||
return "The AI-touched conflict-resolution diff exceeded the configured patch-size limit, so final confirmation was not attempted. No commit was pushed.";
|
||||
}
|
||||
return "goose could not safely complete and validate the conflict resolution. The Actions log contains the exact failure stage, and no commit was pushed.";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import {
|
||||
buildConflictPushArgs,
|
||||
buildConflictReviewDiffArgs,
|
||||
canAutoResolveConflicts,
|
||||
describeConflictResolutionFailure,
|
||||
diffSnapshotInventories
|
||||
@@ -33,6 +34,20 @@ test("only a passing conflicted writable current head is eligible", () => {
|
||||
assert.equal(canAutoResolveConflicts({ ...eligible, enabled: false }), false);
|
||||
});
|
||||
|
||||
test("conflict final review scopes the diff to agent-changed files", () => {
|
||||
assert.deepEqual(buildConflictReviewDiffArgs(["server.js", "public/js/app.js"]), [
|
||||
"diff",
|
||||
"--cached",
|
||||
"--no-ext-diff",
|
||||
"--unified=80",
|
||||
"--",
|
||||
"server.js",
|
||||
"public/js/app.js"
|
||||
]);
|
||||
assert.throws(() => buildConflictReviewDiffArgs([]), /at least one agent-changed file/);
|
||||
assert.throws(() => buildConflictReviewDiffArgs([".env"]), /protected path/);
|
||||
});
|
||||
|
||||
test("conflict failures are actionable without exposing raw command output", () => {
|
||||
assert.match(
|
||||
describeConflictResolutionFailure(new Error("fatal: refusing to merge unrelated histories")),
|
||||
|
||||
Reference in new issue
Block a user