sandlot merge <branch>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Wanstrath 2026-02-17 19:13:11 -08:00
parent 19a1d0c563
commit cedf6705ef
2 changed files with 23 additions and 0 deletions

View File

@ -115,6 +115,21 @@ const closeAction = async (branch: string) => {
}
}
// ── sandlot merge <branch> ──────────────────────────────────────────
program
.command("merge")
.argument("<branch>", "branch name")
.description("Merge a branch into main and close the session")
.action(async (branch: string) => {
const root = await git.repoRoot()
await git.merge(branch, root)
console.log(`Merged ${branch} into current branch`)
await closeAction(branch)
})
program
.command("close")
.argument("<branch>", "branch name")

View File

@ -80,3 +80,11 @@ export async function checkout(branch: string, cwd: string): Promise<void> {
throw new Error(`Failed to checkout branch "${branch}": ${result.stderr.toString().trim()}`)
}
}
/** Merge a branch into the current branch. */
export async function merge(branch: string, cwd: string): Promise<void> {
const result = await $`git merge ${branch}`.cwd(cwd).nothrow().quiet()
if (result.exitCode !== 0) {
throw new Error(`Failed to merge branch "${branch}": ${result.stderr.toString().trim()}`)
}
}