From fcc3c39dad0b2db06ec672390dc9012f4df6d688 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Mon, 7 Sep 2026 14:03:41 +0800 Subject: [PATCH] =?UTF-8?q?bump-version=20=E6=8F=90=E4=BA=A4=E5=89=8D?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=EF=BC=8C=E5=AD=98=E5=9C=A8=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=9A=82=E5=AD=98=E6=94=B9=E5=8A=A8=E6=97=B6=E4=B8=AD=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - --commit 在改动任何版本文件前先检查已暂存文件,发现版本文件外的暂存改动则中止并提示,避免误提交无关内容 - 同步 AGC 更新技术方案文档说明 --- .../scripts/bump-version.mjs | 32 +++++++++++++++++++ ...方案】AGC客户端更新检查与下载-2026-08-31.md | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/scripts/bump-version.mjs b/apps/ai-game-creator-shell/scripts/bump-version.mjs index 3911ce972..9e4a9eb9a 100644 --- a/apps/ai-game-creator-shell/scripts/bump-version.mjs +++ b/apps/ai-game-creator-shell/scripts/bump-version.mjs @@ -44,7 +44,39 @@ function hasUncommittedVersionChanges() { ); } +function otherStagedFiles() { + const result = spawnSync( + 'git', + ['diff', '--cached', '--name-only'], + { cwd: repoRoot, encoding: 'utf8' }, + ); + if (result.status !== 0) { + throw new Error('无法读取已暂存文件列表'); + } + const versionSet = new Set(versionFiles); + return result.stdout + .split('\n') + .map((file) => file.trim()) + .filter(Boolean) + .filter((file) => !versionSet.has(file)); +} + const { target, commit } = parseArgs(process.argv); + +// 提交前先确认没有其他已暂存改动,避免把无关改动一并提交;若存在则在改动任何文件前中止。 +if (commit) { + const others = otherStagedFiles(); + if (others.length > 0) { + console.error( + `[bump-version] 检测到其他已暂存改动,为避免误提交,请先单独处理后再运行 --commit:\n ${others.join('\n ')}`, + ); + console.error( + '提示:用 git restore --staged 取消暂存,或先提交这些改动。', + ); + process.exit(1); + } +} + const current = readLocalVersion(); // 若版本文件已带着一次未提交的提升(例如先默认跑过一次),再 --commit 时不再重复递增,直接提交现有改动。 diff --git a/docs/technical/【技术方案】AGC客户端更新检查与下载-2026-08-31.md b/docs/technical/【技术方案】AGC客户端更新检查与下载-2026-08-31.md index 4d6fa256a..10a9367e4 100644 --- a/docs/technical/【技术方案】AGC客户端更新检查与下载-2026-08-31.md +++ b/docs/technical/【技术方案】AGC客户端更新检查与下载-2026-08-31.md @@ -59,7 +59,8 @@ npm run ai-game-creator-shell:bump-version -- --version 0.1.25 --commit ``` 若先用默认方式写入版本(未提交),再补 `--commit`,命令会识别到工作区已提升、直接提交现有改动, -**不会重复递增**。提交标题固定为“提升 AGC 版本至 x.y.z”。 +**不会重复递增**。提交前若检测到**除版本文件外的其他已暂存改动**,会中止并提示先处理,避免误提交无关内容。 +提交标题固定为“提升 AGC 版本至 x.y.z”。 **发布只读仓库版本(`npm run ai-game-creator-shell:build` 与 `release:upload`)**