allow optional manual commit message in sandlot save, skip AI generation when provided
This commit is contained in:
parent
ec697565ac
commit
9f250188ca
17
src/cli.ts
17
src/cli.ts
|
|
@ -146,8 +146,9 @@ program
|
|||
program
|
||||
.command("save")
|
||||
.argument("<branch>", "branch name")
|
||||
.description("Stage all changes and commit with an AI-generated message")
|
||||
.action(async (branch: string) => {
|
||||
.argument("[message]", "commit message (AI-generated if omitted)")
|
||||
.description("Stage all changes and commit")
|
||||
.action(async (branch: string, message?: string) => {
|
||||
const root = await git.repoRoot()
|
||||
const session = await state.getSession(root, branch)
|
||||
if (!session) {
|
||||
|
|
@ -169,6 +170,10 @@ program
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
let msg: string
|
||||
if (message) {
|
||||
msg = message
|
||||
} else {
|
||||
spin.text = "Generating commit message"
|
||||
const gen = await vm.exec(
|
||||
worktreeAbs,
|
||||
|
|
@ -179,17 +184,19 @@ program
|
|||
if (gen.stderr) console.error(gen.stderr)
|
||||
process.exit(1)
|
||||
}
|
||||
const { stdout } = await vm.exec(worktreeAbs, "cat /tmp/sandlot_commit_msg")
|
||||
await vm.exec(worktreeAbs, "rm -f /tmp/sandlot_commit_msg")
|
||||
msg = stdout
|
||||
}
|
||||
|
||||
spin.text = "Committing"
|
||||
const commit = await vm.exec(worktreeAbs, "git commit -F /tmp/sandlot_commit_msg")
|
||||
const commit = await vm.exec(worktreeAbs, `git commit -m ${JSON.stringify(msg)}`)
|
||||
if (commit.exitCode !== 0) {
|
||||
spin.fail("Commit failed")
|
||||
if (commit.stderr) console.error(commit.stderr)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const { stdout: msg } = await vm.exec(worktreeAbs, "cat /tmp/sandlot_commit_msg")
|
||||
await vm.exec(worktreeAbs, "rm -f /tmp/sandlot_commit_msg")
|
||||
spin.succeed(`Saved: ${msg}`)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user