Compare commits
3 Commits
0cde238bc1
...
392d3c787b
| Author | SHA1 | Date | |
|---|---|---|---|
| 392d3c787b | |||
| 920b4d12b4 | |||
| bcca8808f3 |
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@because/sandlot",
|
"name": "@because/sandlot",
|
||||||
"version": "0.0.11",
|
"version": "0.0.12",
|
||||||
"description": "Sandboxed, branch-based development with Claude",
|
"description": "Sandboxed, branch-based development with Claude",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
|
||||||
|
|
@ -128,14 +128,16 @@ program
|
||||||
program
|
program
|
||||||
.command("merge")
|
.command("merge")
|
||||||
.argument("<branch>", "branch name")
|
.argument("<branch>", "branch name")
|
||||||
|
.option("-f, --force", "allow merging into a non-main branch")
|
||||||
.description("Merge a branch into main and close the session")
|
.description("Merge a branch into main and close the session")
|
||||||
.action(mergeAction)
|
.action((branch: string, opts: { force?: boolean }) => mergeAction(branch, opts))
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("squash")
|
.command("squash")
|
||||||
.argument("<branch>", "branch name")
|
.argument("<branch>", "branch name")
|
||||||
|
.option("-f, --force", "allow merging into a non-main branch")
|
||||||
.description("Squash-merge a branch into main and close the session")
|
.description("Squash-merge a branch into main and close the session")
|
||||||
.action(squashAction)
|
.action((branch: string, opts: { force?: boolean }) => squashAction(branch, opts))
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("rebase")
|
.command("rebase")
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,13 @@ export async function resolveConflicts(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Merge (or squash-merge) a branch into main, resolve conflicts if needed, and close the session. */
|
/** 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<void> {
|
export async function mergeAndClose(branch: string, opts?: { squash?: boolean; force?: boolean }): Promise<void> {
|
||||||
const root = await git.repoRoot()
|
const root = await git.repoRoot()
|
||||||
|
const main = await git.mainBranch(root)
|
||||||
|
const current = await git.currentBranch(root)
|
||||||
|
if (current !== main && !opts?.force) {
|
||||||
|
die(`You must be on "${main}" to merge. Currently on "${current}". Use --force to merge into "${current}" anyway.`)
|
||||||
|
}
|
||||||
const session = await state.getSession(root, branch)
|
const session = await state.getSession(root, branch)
|
||||||
|
|
||||||
if (session && await git.isDirty(session.worktree)) {
|
if (session && await git.isDirty(session.worktree)) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { mergeAndClose } from "./helpers.ts"
|
import { mergeAndClose } from "./helpers.ts"
|
||||||
|
|
||||||
export async function action(branch: string) {
|
export async function action(branch: string, opts?: { force?: boolean }) {
|
||||||
await mergeAndClose(branch)
|
await mergeAndClose(branch, { force: opts?.force })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { mergeAndClose } from "./helpers.ts"
|
import { mergeAndClose } from "./helpers.ts"
|
||||||
|
|
||||||
export async function action(branch: string) {
|
export async function action(branch: string, opts?: { force?: boolean }) {
|
||||||
await mergeAndClose(branch, { squash: true })
|
await mergeAndClose(branch, { squash: true, force: opts?.force })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user