fix(commit): handle no-change analysis
This commit is contained in:
@@ -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
@@ -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",
|
||||||
|
|||||||
Generated
+1807
-181
File diff suppressed because it is too large
Load Diff
+32
-4
@@ -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":
|
||||||
nextCommitObject = await runAnalyzeStep();
|
try {
|
||||||
|
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;
|
||||||
? await runWithSuppressedOutput(recommendationBuilder)
|
try {
|
||||||
: await recommendationBuilder();
|
recommendation = mode.json
|
||||||
|
? await runWithSuppressedOutput(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);
|
||||||
|
|||||||
Reference in New Issue
Block a user