Merge branch 'show'
This commit is contained in:
commit
997c0967d4
39
src/cli.ts
39
src/cli.ts
|
|
@ -391,6 +391,45 @@ program
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ── sandlot show <branch> ───────────────────────────────────────────
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("show")
|
||||||
|
.argument("<branch>", "branch name")
|
||||||
|
.description("Show the prompt and full diff for a branch (for code review)")
|
||||||
|
.action(async (branch: string) => {
|
||||||
|
const root = await git.repoRoot()
|
||||||
|
const session = await state.getSession(root, branch)
|
||||||
|
if (!session) {
|
||||||
|
console.error(`No session found for branch "${branch}".`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const main = await git.mainBranch(root)
|
||||||
|
const result = await $`git -C ${session.worktree} diff --color=always ${main}...${branch}`.nothrow().quiet()
|
||||||
|
if (result.exitCode !== 0) {
|
||||||
|
console.error("git diff failed")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = ""
|
||||||
|
if (session.prompt) {
|
||||||
|
output += `PROMPT: ${session.prompt}\n\n`
|
||||||
|
}
|
||||||
|
output += result.text()
|
||||||
|
|
||||||
|
const lines = output.split("\n").length
|
||||||
|
const termHeight = process.stdout.rows || 24
|
||||||
|
if (lines > termHeight) {
|
||||||
|
const pager = Bun.spawn(["less", "-R"], { stdin: "pipe", stdout: "inherit", stderr: "inherit" })
|
||||||
|
pager.stdin.write(output)
|
||||||
|
pager.stdin.end()
|
||||||
|
await pager.exited
|
||||||
|
} else {
|
||||||
|
process.stdout.write(output)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// ── sandlot log <branch> ────────────────────────────────────────────
|
// ── sandlot log <branch> ────────────────────────────────────────────
|
||||||
|
|
||||||
program
|
program
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user