refactor(cli): remove interactive prompts for empty states and add clean repo test
Build / bun-build (push) Successful in 29s
Build / bun-build (pull_request) Successful in 37s

This commit is contained in:
2026-06-12 00:42:49 +08:00
parent 14df49b110
commit d0506381f5
2 changed files with 61 additions and 21 deletions
+11 -21
View File
@@ -645,15 +645,6 @@ async function handleCommit(
autoMode: boolean,
dryRun: boolean,
): Promise<"done" | "back"> {
const config = await loadConfig();
if (!config.apiKey) {
console.error(
` ${RED}Error: API key not set. Run ${BOLD}gai config${RESET}${RED} to configure.${RESET}`,
);
process.exit(1);
}
if (!(await isGitRepo())) {
console.error(` ${RED}Error: Not a git repository.${RESET}`);
process.exit(1);
@@ -663,12 +654,7 @@ async function handleCommit(
const unstagedFiles = await getUnstagedFiles();
if (stagedFiles.length === 0 && unstagedFiles.length === 0) {
const choice = await selectOne({
title: "Nothing to commit",
subtitle: "No staged or unstaged changes.",
items: [{ label: "Back", value: "back" as const }],
});
if (choice === null) process.exit(0);
console.log(` ${DIM}Nothing to commit. No staged or unstaged changes.${RESET}`);
return "done";
}
@@ -692,15 +678,19 @@ async function handleCommit(
const diff = await getStagedDiff();
if (!diff) {
const choice = await selectOne({
title: "Nothing to commit",
subtitle: "No staged changes to commit.",
items: [{ label: "Back", value: "back" as const }],
});
if (choice === null) process.exit(0);
console.log(` ${DIM}Nothing to commit. No staged changes to commit.${RESET}`);
return "done";
}
const config = await loadConfig();
if (!config.apiKey) {
console.error(
` ${RED}Error: API key not set. Run ${BOLD}gai config${RESET}${RED} to configure.${RESET}`,
);
process.exit(1);
}
const MAX_DIFF_SIZE = 15000;
const truncatedDiff =
diff.length > MAX_DIFF_SIZE