From 920b4d12b48a5da3086b1c6f7d8b786f102a6e0b Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Fri, 27 Feb 2026 07:45:09 -0800 Subject: [PATCH] Add pre-merge validation in mergeAndClose --- src/commands/helpers.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/commands/helpers.ts b/src/commands/helpers.ts index a5dd416..9c50920 100644 --- a/src/commands/helpers.ts +++ b/src/commands/helpers.ts @@ -93,6 +93,11 @@ export async function resolveConflicts( /** Merge (or squash-merge) a branch into main, resolve conflicts if needed, and close the session. */ export async function mergeAndClose(branch: string, opts?: { squash?: boolean }): Promise { const root = await git.repoRoot() + const main = await git.mainBranch(root) + const current = await git.currentBranch(root) + if (current !== main) { + die(`You must be on "${main}" to merge. Currently on "${current}".`) + } const session = await state.getSession(root, branch) if (session && await git.isDirty(session.worktree)) {