Accept theirs for conflicting lock files instead of deleting them

Removing lock files during conflict resolution caused missing dependencies
after the merge. Checking out theirs and staging preserves a valid lockfile.
This commit is contained in:
Chris Wanstrath 2026-04-07 17:55:40 -07:00
parent 29cbf29b76
commit e694ab06d7

View File

@ -81,7 +81,7 @@ export async function teardownSession(root: string, branch: string, worktree: st
await state.removeSession(root, branch)
}
/** Files that should be removed rather than resolved — they get regenerated. */
/** Lock files to skip AI resolution — accept theirs and move on (basename match covers subdirs too). */
const SKIP_RESOLVE = new Set(["bun.lock", "Cargo.lock"])
/** Resolve conflict markers in files using Claude, then stage them. */
@ -95,7 +95,11 @@ export async function resolveConflicts(
onFile(file, i + 1, files.length)
if (SKIP_RESOLVE.has(basename(file))) {
await $`git rm -f -- ${file}`.cwd(cwd).nothrow().quiet()
const result = await $`git checkout --theirs -- ${file}`.cwd(cwd).nothrow().quiet()
if (result.exitCode !== 0) {
throw new Error(`Failed to resolve lock file ${file}: ${result.stderr.toString().trim()}`)
}
await git.stageFile(file, cwd)
continue
}