@jspg-ai/coding-bb 0.0.3-beta.8 → 0.0.3-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -219,16 +219,18 @@ node "<skill_dir>/scripts/check-repos.js" "<ws_root>"
|
|
|
219
219
|
### 3.2 安全更新 .gitignore(前置)
|
|
220
220
|
|
|
221
221
|
```bash
|
|
222
|
-
node "<skill_dir>/scripts/update-gitignore.js "<ws_root>" "<branch>"
|
|
222
|
+
node "<skill_dir>/scripts/update-gitignore.js" "<ws_root>" "<branch>"
|
|
223
223
|
```
|
|
224
224
|
|
|
225
|
-
脚本内部自动完成:stash 保护 → 切分支 → 添加 `.worktrees/` 和 `.codespace/` → 提交 → 切回 → pop stash
|
|
225
|
+
脚本内部自动完成:stash 保护 → 分支不存在则从 HEAD 创建 → 切分支 → 添加 `.worktrees/` 和 `.codespace/` → 提交 → 切回 → pop stash
|
|
226
226
|
|
|
227
227
|
**解读输出**:
|
|
228
228
|
- 退出码 0 + 末行 `GITIGNORE_OK` → 成功
|
|
229
229
|
- 退出码 2 → 执行失败,**终止流程**
|
|
230
230
|
|
|
231
|
-
>
|
|
231
|
+
> ⓘ **分支自动创建**:本步骤先于 Step 3.3 执行,workspace 分支此时不存在,脚本会自动从 HEAD 创建(与 `create-branches.js` 对 workspace 的行为一致,Step 3.3 报 `reused`)。`.gitignore` 提交正好落在需求分支上,由 Step 3.4 push 一并推送。
|
|
232
|
+
|
|
233
|
+
> ⚠️ 必须在提交后切回主分支,否则 Step 3.5 的 `git worktree add` 会因分支已检出而失败(脚本已自动处理)。
|
|
232
234
|
|
|
233
235
|
### 3.3 创建分支
|
|
234
236
|
|
|
@@ -6,13 +6,13 @@ require('./silence-popup');
|
|
|
6
6
|
* 用法:node update-gitignore.js <ws_root> <branch>
|
|
7
7
|
*
|
|
8
8
|
* 行为:
|
|
9
|
-
* 1. stash
|
|
10
|
-
* 2.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* 1. stash 当前未提交修改(仅 untracked 时不产生 stash)
|
|
10
|
+
* 2. 目标分支不存在则从 HEAD 创建(首跑时分支尚未由 create-branches.js 建立,
|
|
11
|
+
* 顺序无关自愈;create-branches.js 后续会报 reused)
|
|
12
|
+
* 3. 切换到目标分支
|
|
13
|
+
* 4. 检查 .worktrees/ 和 .codespace/ 是否在 .gitignore,缺失则添加并提交
|
|
14
|
+
* 5. 切回原分支
|
|
15
|
+
* 6. pop stash(如有)
|
|
16
16
|
*
|
|
17
17
|
* 幂等:目标分支已在某个 worktree 中检出(init-worktree 重跑场景,上次已处理过
|
|
18
18
|
* .gitignore)时,跳过全部操作直接输出 GITIGNORE_OK——避免 checkout 与 worktree 检出冲突。
|
|
@@ -67,8 +67,12 @@ const status = run('git status --porcelain', wsRoot);
|
|
|
67
67
|
if (status.ok && status.out) {
|
|
68
68
|
const stash = run('git stash push -m "init-worktree-temp"', wsRoot);
|
|
69
69
|
if (stash.ok) {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (/No local changes to save/.test(stash.out)) {
|
|
71
|
+
console.log('ℹ️ 仅 untracked 文件,无需 stash');
|
|
72
|
+
} else {
|
|
73
|
+
stashed = true;
|
|
74
|
+
console.log('✅ 已 stash 未提交修改');
|
|
75
|
+
}
|
|
72
76
|
} else {
|
|
73
77
|
console.error('❌ git stash 失败:' + stash.err);
|
|
74
78
|
process.exit(2);
|
|
@@ -77,6 +81,18 @@ if (status.ok && status.out) {
|
|
|
77
81
|
console.log('ℹ️ 无未提交修改,跳过 stash');
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
// 2.1 目标分支不存在则从 HEAD 创建(Step 3.2 先于 Step 3.3 执行时分支尚未建立)
|
|
85
|
+
const branchList = run('git branch --list "' + branch + '"', wsRoot);
|
|
86
|
+
if (branchList.ok && !branchList.out) {
|
|
87
|
+
const create = run('git branch "' + branch + '"', wsRoot);
|
|
88
|
+
if (!create.ok) {
|
|
89
|
+
console.error('❌ 创建分支 ' + branch + ' 失败:' + create.err);
|
|
90
|
+
if (stashed) run('git stash pop', wsRoot);
|
|
91
|
+
process.exit(2);
|
|
92
|
+
}
|
|
93
|
+
console.log('✅ 分支 ' + branch + ' 不存在,已从 HEAD 创建');
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
// 3. 切换到目标分支
|
|
81
97
|
const checkout = run('git checkout "' + branch + '"', wsRoot);
|
|
82
98
|
if (!checkout.ok) {
|