Skip to content

Commit a878bad

Browse files
skulidropekclaude
andcommitted
fix(state-repo): abort merge on conflict and let stateSync open a PR
Remove -X ours: conflicts are not auto-resolved. Instead, on a failed merge the repo is restored via --abort and stateSync handles the rest — it will push a branch and log a PR URL for manual resolution. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f8c0b99 commit a878bad

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

packages/lib/src/usecases/state-repo.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,18 @@ const adoptRemoteHistoryIfOrphan = (
253253
return // Histories are related — normal rebase in stateSync will handle it
254254
}
255255

256-
// Merge unrelated histories so both are preserved; prefer local on conflict
256+
// Merge unrelated histories so both are preserved; abort on conflict — stateSync will open a PR
257257
yield* _(Effect.logWarning(`Local history has no common ancestor with ${remoteRef}; merging unrelated histories`))
258-
yield* _(
259-
git(
260-
root,
261-
["merge", "--allow-unrelated-histories", "--no-edit", "-s", "recursive", "-X", "ours", remoteRef],
262-
gitBaseEnv
263-
)
258+
const mergeExit = yield* _(
259+
gitExitCode(root, ["merge", "--allow-unrelated-histories", "--no-edit", remoteRef], gitBaseEnv)
264260
)
265-
yield* _(Effect.log(`Merged unrelated histories from ${remoteRef}`))
261+
if (mergeExit === successExitCode) {
262+
yield* _(Effect.log(`Merged unrelated histories from ${remoteRef}`))
263+
return
264+
}
265+
// Conflict — abort and leave resolution to stateSync (which will push a branch and log a PR URL)
266+
yield* _(gitExitCode(root, ["merge", "--abort"], gitBaseEnv))
267+
yield* _(Effect.logWarning(`Merge conflict with ${remoteRef}; sync will open a PR for manual resolution`))
266268
})
267269

268270
export const stateInit = (

0 commit comments

Comments
 (0)