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
|
program
|
||||||
.command("save")
|
.command("save")
|
||||||
.argument("<branch>", "branch name")
|
.argument("<branch>", "branch name")
|
||||||
.description("Stage all changes and commit with an AI-generated message")
|
.argument("[message]", "commit message (AI-generated if omitted)")
|
||||||
.action(async (branch: string) => {
|
.description("Stage all changes and commit")
|
||||||
|
.action(async (branch: string, message?: string) => {
|
||||||
const root = await git.repoRoot()
|
const root = await git.repoRoot()
|
||||||
const session = await state.getSession(root, branch)
|
const session = await state.getSession(root, branch)
|
||||||
if (!session) {
|
if (!session) {
|
||||||
|
|
@ -169,6 +170,10 @@ program
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let msg: string
|
||||||
|
if (message) {
|
||||||
|
msg = message
|
||||||
|
} else {
|
||||||
spin.text = "Generating commit message"
|
spin.text = "Generating commit message"
|
||||||
const gen = await vm.exec(
|
const gen = await vm.exec(
|
||||||
worktreeAbs,
|
worktreeAbs,
|
||||||
|
|
@ -179,17 +184,19 @@ program
|
||||||
if (gen.stderr) console.error(gen.stderr)
|
if (gen.stderr) console.error(gen.stderr)
|
||||||
process.exit(1)
|
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"
|
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) {
|
if (commit.exitCode !== 0) {
|
||||||
spin.fail("Commit failed")
|
spin.fail("Commit failed")
|
||||||
if (commit.stderr) console.error(commit.stderr)
|
if (commit.stderr) console.error(commit.stderr)
|
||||||
process.exit(1)
|
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}`)
|
spin.succeed(`Saved: ${msg}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user