refactor(cli): remove interactive prompts for empty states and add clean repo test
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user