ai-git-tools 2.0.19 → 2.0.20
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.
- package/README.md +39 -1
- package/package.json +1 -1
- package/src/pr-modules/core/workflow.js +25 -2
package/README.md
CHANGED
|
@@ -211,7 +211,7 @@ export default {
|
|
|
211
211
|
|
|
212
212
|
// GitHub 設定
|
|
213
213
|
github: {
|
|
214
|
-
defaultBase: 'release', //
|
|
214
|
+
defaultBase: 'release', // 預設目標分支:'release'=自動查找最新,或指定具體分支名
|
|
215
215
|
autoLabels: true, // 自動添加 Labels
|
|
216
216
|
},
|
|
217
217
|
|
|
@@ -231,6 +231,44 @@ export default {
|
|
|
231
231
|
};
|
|
232
232
|
\`\`\`
|
|
233
233
|
|
|
234
|
+
### defaultBase 配置說明
|
|
235
|
+
|
|
236
|
+
\`defaultBase\` 支援兩種模式:
|
|
237
|
+
|
|
238
|
+
#### 1. 自動模式(推薦)
|
|
239
|
+
```javascript
|
|
240
|
+
github: {
|
|
241
|
+
defaultBase: 'release', // 自動查找最新的 release 分支
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
- 工具會自動偵測所有 \`release-*\` 或 \`release/*\` 格式的分支
|
|
245
|
+
- 自動選擇最新版本(優先選擇月度分支,如 release-2025-m12.1)
|
|
246
|
+
- 適合經常更新 release 版本的專案
|
|
247
|
+
|
|
248
|
+
#### 2. 具體分支模式
|
|
249
|
+
```javascript
|
|
250
|
+
github: {
|
|
251
|
+
defaultBase: 'release-2025-m12.1', // 固定使用此分支
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
- 直接使用指定的分支名稱
|
|
255
|
+
- 適合需要固定某個版本的情況
|
|
256
|
+
- 或使用 \`main\`、\`develop\` 等標準分支
|
|
257
|
+
|
|
258
|
+
**範例輸出**:
|
|
259
|
+
```bash
|
|
260
|
+
# 使用 defaultBase: 'release'
|
|
261
|
+
配置檔指定使用 release 分支,正在偵測最新版本...
|
|
262
|
+
📋 偵測到的 release 分支:
|
|
263
|
+
月度分支 (優先):
|
|
264
|
+
1. release-2025-m12.1 ← 最新
|
|
265
|
+
2. release-2025-m11.1
|
|
266
|
+
✅ 自動選擇最新 release 分支: release-2025-m12.1
|
|
267
|
+
|
|
268
|
+
# 使用 defaultBase: 'release-2025-m12.1'
|
|
269
|
+
✅ 使用配置檔指定的分支: release-2025-m12.1
|
|
270
|
+
```
|
|
271
|
+
|
|
234
272
|
## 🔧 環境需求
|
|
235
273
|
|
|
236
274
|
- **Node.js** >= 18.0.0
|
package/package.json
CHANGED
|
@@ -101,8 +101,31 @@ export class PRWorkflow {
|
|
|
101
101
|
if (!baseBranch) {
|
|
102
102
|
// 優先使用配置檔中的 defaultBase
|
|
103
103
|
if (this.config.github?.defaultBase) {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const defaultBase = this.config.github.defaultBase;
|
|
105
|
+
|
|
106
|
+
// 如果 defaultBase 是 'release',則自動查找最新的 release 分支
|
|
107
|
+
if (defaultBase === 'release' || defaultBase.match(/^release$/i)) {
|
|
108
|
+
log.step('配置檔指定使用 release 分支,正在偵測最新版本...\n');
|
|
109
|
+
const allBranches = this.git.detectReleaseBranches();
|
|
110
|
+
const latestRelease = this.git.findLatestReleaseBranch();
|
|
111
|
+
|
|
112
|
+
if (latestRelease) {
|
|
113
|
+
baseBranch = latestRelease;
|
|
114
|
+
this.displayDetectedBranches(allBranches, latestRelease);
|
|
115
|
+
log.success(`自動選擇最新 release 分支: ${baseBranch}`);
|
|
116
|
+
log.info(`提示: 使用 --base <分支名> 指定其他分支\n`);
|
|
117
|
+
} else {
|
|
118
|
+
throw new PRError('未偵測到任何 release 分支', 'NO_RELEASE_BRANCH', [
|
|
119
|
+
'使用 --base 參數指定目標分支',
|
|
120
|
+
'或在 .ai-git-config.js 中設置具體的分支名(如 release-2025-m12.1)',
|
|
121
|
+
'確認遠端分支存在: git branch -r | grep release',
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
// 使用配置檔中指定的具體分支名
|
|
126
|
+
baseBranch = defaultBase;
|
|
127
|
+
log.success(`使用配置檔指定的分支: ${baseBranch}\n`);
|
|
128
|
+
}
|
|
106
129
|
} else {
|
|
107
130
|
// 如果沒有配置,則自動偵測最新的 release 分支
|
|
108
131
|
log.step('正在偵測 release 分支...\n');
|