From d508e1d06cfd578046263376d599137a8b6377e4 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Thu, 4 Dec 2025 11:13:31 +0000 Subject: [PATCH] fix(commit): Prevent auto-accept for BREAKING CHANGE commits; require manual confirmation and warn when --yes is used --- changelog.md | 8 ++++++++ ts/00_commitinfo_data.ts | 2 +- ts/mod_commit/index.ts | 12 ++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 594a62c..0b41db3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2025-12-04 - 2.2.1 - fix(commit) +Prevent auto-accept for BREAKING CHANGE commits; require manual confirmation and warn when --yes is used + +- Do not auto-accept AI commit recommendations when the suggested change is a BREAKING CHANGE (major bump). +- Only auto-accept recommendations when -y/--yes is provided and the change is not breaking. +- When --yes is provided but the recommendation is a breaking change, log a warning and fall back to interactive confirmation. +- Introduced isBreakingChange and canAutoAccept flags to centralize the auto-accept logic. + ## 2025-12-02 - 2.2.0 - feat(services) Improve services manager and configuration; switch test templates to @git.zone/tstest; bump dev dependencies and update docs diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 9cc5828..b1347d8 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/cli', - version: '2.2.0', + version: '2.2.1', description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.' } diff --git a/ts/mod_commit/index.ts b/ts/mod_commit/index.ts index c1b68a9..b74c069 100644 --- a/ts/mod_commit/index.ts +++ b/ts/mod_commit/index.ts @@ -30,8 +30,12 @@ export const run = async (argvArg: any) => { let answerBucket: plugins.smartinteract.AnswerBucket; - // Check if -y or --yes flag is set to auto-accept recommendations - if (argvArg.y || argvArg.yes) { + // Check if -y/--yes flag is set AND version is not a breaking change + // Breaking changes (major version bumps) always require manual confirmation + const isBreakingChange = nextCommitObject.recommendedNextVersionLevel === 'BREAKING CHANGE'; + const canAutoAccept = (argvArg.y || argvArg.yes) && !isBreakingChange; + + if (canAutoAccept) { // Auto-mode: create AnswerBucket programmatically logger.log('info', '✓ Auto-accepting AI recommendations (--yes flag)'); @@ -53,6 +57,10 @@ export const run = async (argvArg: any) => { value: !!(argvArg.p || argvArg.push), // Only push if -p flag also provided }); } else { + // Warn if --yes was provided but we're requiring confirmation due to breaking change + if (isBreakingChange && (argvArg.y || argvArg.yes)) { + logger.log('warn', '⚠️ BREAKING CHANGE detected - manual confirmation required'); + } // Interactive mode: prompt user for input const commitInteract = new plugins.smartinteract.SmartInteract(); commitInteract.addQuestions([