sandlot merge <branch>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
19a1d0c563
commit
cedf6705ef
15
src/cli.ts
15
src/cli.ts
|
|
@ -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
|
program
|
||||||
.command("close")
|
.command("close")
|
||||||
.argument("<branch>", "branch name")
|
.argument("<branch>", "branch name")
|
||||||
|
|
|
||||||
|
|
@ -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()}`)
|
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()}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user