fix(commit): handle no-change analysis

This commit is contained in:
2026-05-24 05:21:47 +00:00
parent 5da1660c3e
commit d5027174dd
4 changed files with 1845 additions and 186 deletions
+5
View File
@@ -2,6 +2,11 @@
## Pending ## Pending
### Fixes
- handle empty commit analysis as a clean no-op
- Uses `@git.zone/tsdoc`'s explicit `NoChangesError` signal.
- Makes `gitzone commit` and `gitzone commit recommend --json` return cleanly when no uncommitted changes exist.
## 2026-05-23 - 2.19.2 ## 2026-05-23 - 2.19.2
+1 -1
View File
@@ -63,7 +63,7 @@
"@types/node": "^25.4.0" "@types/node": "^25.4.0"
}, },
"dependencies": { "dependencies": {
"@git.zone/tsdoc": "^2.0.0", "@git.zone/tsdoc": "^2.0.6",
"@git.zone/tspublish": "^1.11.2", "@git.zone/tspublish": "^1.11.2",
"@push.rocks/commitinfo": "^1.0.12", "@push.rocks/commitinfo": "^1.0.12",
"@push.rocks/early": "^4.0.4", "@push.rocks/early": "^4.0.4",
+1807 -181
View File
File diff suppressed because it is too large Load Diff
+29 -1
View File
@@ -9,6 +9,13 @@ import { getCliMode, printJson, runWithSuppressedOutput } from "../helpers.climo
import { appendPendingChangelogEntry } from "../helpers.changelog.js"; import { appendPendingChangelogEntry } from "../helpers.changelog.js";
import { resolveCommitWorkflow, type IResolvedCommitWorkflow } from "../helpers.workflow.js"; import { resolveCommitWorkflow, type IResolvedCommitWorkflow } from "../helpers.workflow.js";
const isNoChangesError = (error: unknown): boolean => {
return (
error instanceof plugins.tsdoc.NoChangesError ||
(error instanceof Error && error.name === "NoChangesError")
);
};
export const run = async (argvArg: any) => { export const run = async (argvArg: any) => {
const mode = await getCliMode(argvArg); const mode = await getCliMode(argvArg);
const subcommand = argvArg._?.[1]; const subcommand = argvArg._?.[1];
@@ -65,7 +72,15 @@ export const run = async (argvArg: any) => {
await runCommandStep(smartshellInstance, "Running build", workflow.buildCommand); await runCommandStep(smartshellInstance, "Running build", workflow.buildCommand);
break; break;
case "analyze": case "analyze":
try {
nextCommitObject = await runAnalyzeStep(); nextCommitObject = await runAnalyzeStep();
} catch (error) {
if (isNoChangesError(error)) {
logger.log("info", "No uncommitted changes found. Nothing to commit.");
return;
}
throw error;
}
answerBucket = await buildAnswerBucket(nextCommitObject, workflow, mode, argvArg); answerBucket = await buildAnswerBucket(nextCommitObject, workflow, mode, argvArg);
break; break;
case "changelog": case "changelog":
@@ -284,9 +299,22 @@ async function handleRecommend(mode: ICliMode): Promise<void> {
} }
}; };
const recommendation = mode.json let recommendation: any;
try {
recommendation = mode.json
? await runWithSuppressedOutput(recommendationBuilder) ? await runWithSuppressedOutput(recommendationBuilder)
: await recommendationBuilder(); : await recommendationBuilder();
} catch (error) {
if (isNoChangesError(error)) {
if (mode.json) {
printJson({ ok: true, noChanges: true });
} else {
logger.log("info", "No uncommitted changes found.");
}
return;
}
throw error;
}
if (mode.json) { if (mode.json) {
printJson(recommendation); printJson(recommendation);