Add dirty worktree check before merge to prevent unsaved changes from being lost

This commit is contained in:
Chris Wanstrath 2026-02-20 08:27:34 -08:00
parent 9b8d4d882e
commit 7c46b28aab

View File

@ -413,6 +413,12 @@ program
.description("Merge a branch into main and close the session")
.action(async (branch: string) => {
const root = await git.repoRoot()
const session = await state.getSession(root, branch)
if (session && await git.isDirty(session.worktree)) {
console.error(`✖ Branch "${branch}" has unsaved changes. Run "sandlot save ${branch}" first.`)
process.exit(1)
}
const conflicts = await git.merge(branch, root)