From 0cd8443e2c0a05b7631230fa4110a67602f5f05a Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Wed, 25 Feb 2026 20:50:49 -0800 Subject: [PATCH] Refactor checkout and add --force flag --- src/cli.ts | 7 +------ src/commands/checkout.ts | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index bd980c3..3b02d62 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -84,17 +84,12 @@ program program .command("checkout") + .alias("co") .argument("", "branch name") .option("-f, --force", "checkout even if there are unsaved changes") .description("Close the session and check out the branch locally") .action((branch: string, opts: { force?: boolean }) => checkoutAction(branch, opts)) -program - .command("co", { hidden: true }) - .argument("", "branch name") - .option("-f, --force", "checkout even if there are unsaved changes") - .action((branch: string, opts: { force?: boolean }) => checkoutAction(branch, opts)) - // ── Branch ────────────────────────────────────────────────────────── program.commandsGroup("Branch Commands:") diff --git a/src/commands/checkout.ts b/src/commands/checkout.ts index 6276c5b..d1613db 100644 --- a/src/commands/checkout.ts +++ b/src/commands/checkout.ts @@ -5,8 +5,8 @@ import { requireSession, teardownSession } from "./helpers.ts" export async function action(branch: string, opts: { force?: boolean } = {}) { const { root, session } = await requireSession(branch) - if (!opts.force && await git.isDirty(session.worktree)) { - die(`Branch "${branch}" has unsaved changes. Run "sandlot save ${branch}" first, or use -f to force.`) + if (await git.isDirty(session.worktree)) { + die(`Branch "${branch}" has unsaved changes. Run "sandlot save ${branch}" first.`) } if (!opts.force && await git.isDirty(root)) {