@zjex/git-workflow 0.2.24 → 0.3.0
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/.github/workflows/deploy-docs.yml +68 -0
- package/.github/workflows/test.yml +24 -4
- package/.husky/pre-commit +14 -0
- package/README.md +72 -1066
- package/dist/index.js +103 -13
- package/docs/.vitepress/cache/deps/_metadata.json +52 -0
- package/docs/.vitepress/cache/deps/chunk-2CLQ7TTZ.js +9719 -0
- package/docs/.vitepress/cache/deps/chunk-2CLQ7TTZ.js.map +7 -0
- package/docs/.vitepress/cache/deps/chunk-LE5NDSFD.js +12824 -0
- package/docs/.vitepress/cache/deps/chunk-LE5NDSFD.js.map +7 -0
- package/docs/.vitepress/cache/deps/package.json +3 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4505 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +583 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +1352 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +1665 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js +1813 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js.map +7 -0
- package/docs/.vitepress/cache/deps/vue.js +347 -0
- package/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-2CLQ7TTZ.js +9719 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-2CLQ7TTZ.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-LE5NDSFD.js +12824 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/chunk-LE5NDSFD.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/package.json +3 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vue_devtools-api.js +4505 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_core.js +583 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_core.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_integrations_useFocusTrap.js +1352 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___mark__js_src_vanilla__js.js +1665 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___mark__js_src_vanilla__js.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___minisearch.js +1813 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vitepress___minisearch.js.map +7 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vue.js +347 -0
- package/docs/.vitepress/cache/deps_temp_44e2fb0f/vue.js.map +7 -0
- package/docs/.vitepress/config.ts +167 -0
- package/docs/.vitepress/theme/custom.css +39 -0
- package/docs/.vitepress/theme/index.ts +4 -0
- package/docs/README.md +82 -0
- package/docs/commands/branch.md +468 -0
- package/docs/commands/commit.md +554 -0
- package/docs/commands/config.md +346 -0
- package/docs/commands/index.md +312 -0
- package/docs/commands/interactive.md +384 -0
- package/docs/commands/release.md +300 -0
- package/docs/commands/stash.md +309 -0
- package/docs/commands/tag.md +278 -0
- package/docs/commands/update.md +347 -0
- package/docs/config/ai-config.md +160 -0
- package/docs/config/branch-config.md +133 -0
- package/docs/config/commit-config.md +185 -0
- package/docs/config/config-file.md +776 -0
- package/docs/config/examples.md +279 -0
- package/docs/config/index.md +478 -0
- package/docs/guide/ai-commit.md +576 -0
- package/docs/guide/basic-usage.md +522 -0
- package/docs/guide/best-practices.md +426 -0
- package/docs/guide/branch-management.md +712 -0
- package/docs/guide/getting-started.md +294 -0
- package/docs/guide/index.md +168 -0
- package/docs/guide/installation.md +449 -0
- package/docs/guide/release-management.md +744 -0
- package/docs/guide/stash-management.md +608 -0
- package/docs/guide/tag-management.md +614 -0
- package/docs/index.md +205 -0
- package/docs/public/favicon.svg +21 -0
- package/docs/public/hero-logo.svg +43 -0
- package/docs/public/logo.svg +20 -0
- package/package.json +11 -2
- package/scripts/publish.js +55 -8
- package/scripts/publish.sh +20 -2
- package/scripts/release.sh +20 -2
- package/scripts/update-test-count.js +55 -0
- package/src/ai-service.ts +101 -15
- package/src/commands/init.ts +18 -0
- package/src/config.ts +1 -0
- package/tests/ai-service.test.ts +237 -2
- package/tests/help.test.ts +134 -0
- package/tests/init.test.ts +582 -0
- package/tests/release.test.ts +333 -0
- package/tests/setup.ts +21 -0
- package/tests/stash.test.ts +376 -0
- package/tests/update.test.ts +402 -0
- package/vitest.config.ts +3 -0
- package/zjex-logo.svg +22 -0
- package/zjex-optimized.svg +34 -0
- package/zjex.svg +1 -0
package/README.md
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# @zjex/git-workflow
|
|
2
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://iamzjt-front-end.github.io/git-workflow/">
|
|
5
|
+
<img src="./zjex-logo.svg" alt="zjex logo" width="200" />
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
3
9
|
<p align="center">
|
|
4
10
|
<a href="https://www.npmjs.com/package/@zjex/git-workflow"><img src="https://img.shields.io/npm/v/@zjex/git-workflow?style=flat&colorA=18181B&colorB=F0DB4F" alt="npm version"></a>
|
|
5
11
|
<a href="https://www.npmjs.com/package/@zjex/git-workflow"><img src="https://img.shields.io/npm/dt/@zjex/git-workflow?style=flat&colorA=18181B&colorB=3178C6" alt="npm downloads"></a>
|
|
6
12
|
<a href="https://github.com/iamzjt-front-end/git-workflow"><img src="https://img.shields.io/github/stars/iamzjt-front-end/git-workflow?style=flat&colorA=18181B&colorB=F59E0B" alt="github stars"></a>
|
|
7
13
|
<a href="https://github.com/iamzjt-front-end/git-workflow/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@zjex/git-workflow?style=flat&colorA=18181B&colorB=10B981" alt="license"></a>
|
|
8
14
|
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-339933?style=flat&logo=node.js&logoColor=white&colorA=18181B" alt="node version"></a>
|
|
9
|
-
<a href="https://github.com/iamzjt-front-end/git-workflow/actions"><img src="https://img.shields.io/badge/tests-
|
|
15
|
+
<a href="https://github.com/iamzjt-front-end/git-workflow/actions"><img src="https://img.shields.io/badge/tests-231%20passed-success?style=flat&colorA=18181B" alt="tests"></a>
|
|
10
16
|
<a href="https://github.com/iamzjt-front-end/git-workflow/issues"><img src="https://img.shields.io/github/issues/iamzjt-front-end/git-workflow?style=flat&colorA=18181B&colorB=EC4899" alt="issues"></a>
|
|
11
17
|
</p>
|
|
12
18
|
|
|
@@ -15,11 +21,14 @@
|
|
|
15
21
|
</p>
|
|
16
22
|
|
|
17
23
|
<p align="center">
|
|
18
|
-
<a href="#✨-特性">特性</a> •
|
|
19
24
|
<a href="#⚡️-快速开始">快速开始</a> •
|
|
20
|
-
<a href="
|
|
21
|
-
<a href="
|
|
22
|
-
<a href="
|
|
25
|
+
<a href="#✨-核心特性">核心特性</a> •
|
|
26
|
+
<a href="#📚-完整文档">完整文档</a> •
|
|
27
|
+
<a href="#🤝-贡献">贡献</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<strong>📚 <a href="https://iamzjt-front-end.github.io/git-workflow/">完整文档</a> | 🚀 <a href="https://iamzjt-front-end.github.io/git-workflow/guide/getting-started">快速开始</a> | 📖 <a href="https://iamzjt-front-end.github.io/git-workflow/commands/">命令参考</a> | ⚙️ <a href="https://iamzjt-front-end.github.io/git-workflow/config/">配置指南</a></strong>
|
|
23
32
|
</p>
|
|
24
33
|
|
|
25
34
|
---
|
|
@@ -37,65 +46,32 @@
|
|
|
37
46
|
|
|
38
47
|
**git-workflow** 就是为解决这些痛点而生的。它提供了一套简洁的命令,让你专注于编码,而不是 Git 操作。
|
|
39
48
|
|
|
40
|
-
## ✨
|
|
41
|
-
|
|
42
|
-
###
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
###
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
- ✅ 智能版本递增(patch/minor/major)
|
|
67
|
-
- ✅ 支持预发布版本(alpha/beta/rc)
|
|
68
|
-
- ✅ 预发布版本可升级或转正式版本
|
|
69
|
-
- ✅ 自动推送到远程
|
|
70
|
-
- ✅ 支持删除和修改 tag
|
|
71
|
-
|
|
72
|
-
### Commit 管理
|
|
73
|
-
|
|
74
|
-
- ✅ AI 自动生成 commit message(2-3 秒完成)
|
|
75
|
-
- ✅ 支持 4 种 AI 提供商(GitHub/OpenAI/Claude/Ollama)
|
|
76
|
-
- ✅ 手动模式支持 11 种提交类型
|
|
77
|
-
- ✅ 自动添加 Gitmoji 表情
|
|
78
|
-
- ✅ 支持 scope、详细描述、关联 Issue
|
|
79
|
-
- ✅ 支持标记破坏性变更(BREAKING CHANGE)
|
|
80
|
-
- ✅ 提交前预览,可取消
|
|
81
|
-
- ✅ 自动暂存或手动选择文件
|
|
82
|
-
|
|
83
|
-
### 配置灵活
|
|
84
|
-
|
|
85
|
-
- ⚙️ 支持项目级配置文件(`.gwrc.json`)
|
|
86
|
-
- ⚙️ 不同项目可使用不同规范
|
|
87
|
-
- ⚙️ 支持自定义分支前缀、ID 标签等
|
|
88
|
-
- ⚙️ 支持自定义 commit emoji
|
|
89
|
-
- ⚙️ 支持配置 AI 提供商和模型
|
|
90
|
-
|
|
91
|
-
### 用户体验
|
|
92
|
-
|
|
93
|
-
- 🎨 优雅的命令行界面
|
|
94
|
-
- 🎯 键盘快捷操作(方向键、空格、回车)
|
|
95
|
-
- 🔍 实时搜索和过滤
|
|
96
|
-
- 📋 详细的操作提示和错误信息
|
|
97
|
-
- 🚫 优雅处理 Ctrl+C 退出
|
|
98
|
-
- 📦 轻量依赖,安装快速
|
|
49
|
+
## ✨ 核心特性
|
|
50
|
+
|
|
51
|
+
### 🤖 AI 智能提交
|
|
52
|
+
- 使用 AI 自动分析代码变更生成 commit message(2-3 秒完成)
|
|
53
|
+
- 支持 GitHub Models(免费)、OpenAI、Claude、Ollama 等多种提供商
|
|
54
|
+
- 遵循 Conventional Commits + Gitmoji 规范
|
|
55
|
+
|
|
56
|
+
### 🎯 规范分支管理
|
|
57
|
+
- 自动生成带日期的规范分支名(`feature/20260109-PROJ-123-add-login`)
|
|
58
|
+
- 智能检测基础分支(main/master),支持自定义
|
|
59
|
+
- 一键删除本地+远程分支,按最近使用排序
|
|
60
|
+
|
|
61
|
+
### 🏷️ 智能版本管理
|
|
62
|
+
- 自动识别当前版本,交互式选择下一版本
|
|
63
|
+
- 支持 semver + 预发布版本(alpha/beta/rc)
|
|
64
|
+
- 自动检测 tag 前缀,支持多种命名规范
|
|
65
|
+
|
|
66
|
+
### 💾 可视化 Stash 管理
|
|
67
|
+
- 清晰的交互式界面,告别难读的 `git stash list`
|
|
68
|
+
- 支持预览、应用、创建分支等操作
|
|
69
|
+
- 智能处理未跟踪文件
|
|
70
|
+
|
|
71
|
+
### ⚙️ 灵活配置
|
|
72
|
+
- 支持全局配置(一次配置,所有项目生效)
|
|
73
|
+
- 支持项目级配置(团队统一规范)
|
|
74
|
+
- 零配置开箱即用,交互式菜单引导操作
|
|
99
75
|
|
|
100
76
|
## ⚡️ 快速开始
|
|
101
77
|
|
|
@@ -176,33 +152,16 @@ gw
|
|
|
176
152
|
[3] 🗑️ 删除分支 gw d
|
|
177
153
|
[4] 📝 提交代码 gw c
|
|
178
154
|
[5] 🏷️ 创建 tag gw t
|
|
179
|
-
|
|
180
|
-
[7] ✏️ 修改 tag gw tu
|
|
181
|
-
[8] 📋 列出 tags gw ts
|
|
182
|
-
[9] 📦 发布版本 gw r
|
|
183
|
-
[a] 💾 管理 stash gw s
|
|
184
|
-
[b] ⚙️ 初始化配置 gw init # 可选择全局或项目配置
|
|
185
|
-
[0] ❓ 帮助
|
|
186
|
-
[q] 退出
|
|
155
|
+
...
|
|
187
156
|
|
|
188
157
|
# ✨ 创建 feature 分支
|
|
189
158
|
gw f
|
|
190
159
|
? 请输入 Story ID (可跳过): PROJ-123
|
|
191
160
|
? 请输入描述: add-user-login
|
|
192
161
|
✔ 分支创建成功: feature/20260109-PROJ-123-add-user-login
|
|
193
|
-
? 是否推送到远程? 是
|
|
194
|
-
✔ 已推送到远程
|
|
195
162
|
|
|
196
|
-
# 📝
|
|
163
|
+
# 📝 AI 智能提交
|
|
197
164
|
gw c
|
|
198
|
-
已暂存的文件:
|
|
199
|
-
src/auth.ts
|
|
200
|
-
src/login.ts
|
|
201
|
-
────────────────────────────────────────
|
|
202
|
-
? 选择 commit 方式:
|
|
203
|
-
❯ 🤖 AI 自动生成 commit message
|
|
204
|
-
✍️ 手动编写 commit message
|
|
205
|
-
|
|
206
165
|
✔ AI 生成完成
|
|
207
166
|
|
|
208
167
|
AI 生成的 commit message:
|
|
@@ -210,932 +169,43 @@ AI 生成的 commit message:
|
|
|
210
169
|
────────────────────────────────────────
|
|
211
170
|
? 使用这个 commit message?
|
|
212
171
|
❯ ✅ 使用
|
|
213
|
-
❌ 不使用,切换到手动模式
|
|
214
172
|
|
|
215
173
|
✔ 提交成功
|
|
216
|
-
commit: a1b2c3d
|
|
217
174
|
|
|
218
175
|
# 🏷️ 创建 tag
|
|
219
176
|
gw t
|
|
220
|
-
? 选择 tag 前缀: v (最新: v1.2.0)
|
|
221
177
|
? 选择版本类型:
|
|
222
178
|
❯ patch → v1.2.1
|
|
223
179
|
minor → v1.3.0
|
|
224
180
|
major → v2.0.0
|
|
225
|
-
alpha → v1.2.1-alpha.1
|
|
226
|
-
beta → v1.2.1-beta.1
|
|
227
|
-
rc → v1.2.1-rc.1
|
|
228
181
|
|
|
229
182
|
✔ Tag 创建成功: v1.2.1
|
|
230
|
-
✔ Tag 已推送: v1.2.1
|
|
231
|
-
|
|
232
|
-
# 🗑️ 删除分支
|
|
233
|
-
gw d
|
|
234
|
-
? 选择要删除的分支:
|
|
235
|
-
❯ feature/20260105-old-feature (本地+远程) 3 days ago
|
|
236
|
-
feature/20260103-test (仅本地) 5 days ago
|
|
237
|
-
|
|
238
|
-
✔ 本地分支已删除: feature/20260105-old-feature
|
|
239
|
-
✔ 远程分支已删除: origin/feature/20260105-old-feature
|
|
240
|
-
|
|
241
|
-
# 💾 管理 stash
|
|
242
|
-
gw s
|
|
243
|
-
共 2 个 stash:
|
|
244
|
-
|
|
245
|
-
? 选择 stash:
|
|
246
|
-
❯ [0] main fix login bug (3 文件) 2 hours ago
|
|
247
|
-
[1] develop add feature (5 文件) 1 day ago
|
|
248
|
-
+ 创建新 stash
|
|
249
|
-
取消
|
|
250
|
-
|
|
251
|
-
? 操作:
|
|
252
|
-
❯ 应用 (保留 stash)
|
|
253
|
-
弹出 (应用并删除)
|
|
254
|
-
创建分支
|
|
255
|
-
查看差异
|
|
256
|
-
删除
|
|
257
|
-
返回列表
|
|
258
|
-
|
|
259
|
-
✔ Stash 已应用
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
## 📚 命令详解
|
|
263
|
-
|
|
264
|
-
### 📋 交互式菜单
|
|
265
|
-
|
|
266
|
-
直接运行 `gw` 显示交互式菜单,适合新手快速上手:
|
|
267
|
-
|
|
268
|
-
```bash
|
|
269
|
-
gw
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
显示 ZJEX Logo 和完整的操作菜单,使用方向键选择,回车确认。
|
|
273
|
-
|
|
274
|
-
### 🌿 分支命令
|
|
275
|
-
|
|
276
|
-
| 命令 | 别名 | 说明 |
|
|
277
|
-
| ------------------------------ | ----------------- | ----------------- |
|
|
278
|
-
| `gw feature [--base <branch>]` | `gw feat`, `gw f` | 创建 feature 分支 |
|
|
279
|
-
| `gw hotfix [--base <branch>]` | `gw fix`, `gw h` | 创建 hotfix 分支 |
|
|
280
|
-
| `gw delete [branch]` | `gw del`, `gw d` | 删除本地/远程分支 |
|
|
281
|
-
|
|
282
|
-
#### 创建分支
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
# 基于 main/master 创建(自动检测)
|
|
286
|
-
gw f
|
|
287
|
-
|
|
288
|
-
# 基于指定分支创建
|
|
289
|
-
gw f --base develop
|
|
290
|
-
gw fix --base release/1.0
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
如果检测到未提交的更改,会询问是否自动暂存 (stash):
|
|
294
|
-
|
|
295
|
-
```bash
|
|
296
|
-
gw f
|
|
297
|
-
# 检测到未提交的更改:
|
|
298
|
-
# M src/index.ts
|
|
299
|
-
# ────────────────────────────────────────
|
|
300
|
-
# ? 是否暂存 (stash) 这些更改后继续?
|
|
301
|
-
# 是
|
|
302
|
-
# 否,取消操作
|
|
303
|
-
# ✔ 更改已暂存,切换分支后可用 gw s 恢复
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
分支命名格式:
|
|
307
|
-
|
|
308
|
-
```
|
|
309
|
-
feature/YYYYMMDD-<ID>-<描述>
|
|
310
|
-
hotfix/YYYYMMDD-<ID>-<描述>
|
|
311
|
-
|
|
312
|
-
# ID 可跳过
|
|
313
|
-
feature/YYYYMMDD-<描述>
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
#### 删除分支
|
|
317
|
-
|
|
318
|
-
```bash
|
|
319
|
-
# 交互式选择(按最近使用排序)
|
|
320
|
-
gw d
|
|
321
|
-
|
|
322
|
-
# 直接删除指定分支
|
|
323
|
-
gw d feature/20260101-old-feature
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
删除时会自动检测远程分支是否存在,并询问是否一并删除。
|
|
327
|
-
|
|
328
|
-
### 🏷️ Tag 命令
|
|
329
|
-
|
|
330
|
-
| 命令 | 别名 | 说明 |
|
|
331
|
-
| ------------------ | ------- | ------------------------ |
|
|
332
|
-
| `gw tags [prefix]` | `gw ts` | 列出 tag(可按前缀过滤) |
|
|
333
|
-
| `gw tag [prefix]` | `gw t` | 交互式创建 tag |
|
|
334
|
-
| `gw tag:delete` | `gw td` | 交互式删除 tag |
|
|
335
|
-
| `gw tag:update` | `gw tu` | 交互式修改 tag 消息 |
|
|
336
|
-
|
|
337
|
-
#### 列出 Tag
|
|
338
|
-
|
|
339
|
-
```bash
|
|
340
|
-
# 列出所有 tag
|
|
341
|
-
gw ts
|
|
342
|
-
|
|
343
|
-
# 按前缀过滤
|
|
344
|
-
gw ts v
|
|
345
|
-
gw ts release-
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
#### 创建 Tag
|
|
349
|
-
|
|
350
|
-
```bash
|
|
351
|
-
# 交互式选择前缀和版本
|
|
352
|
-
gw t
|
|
353
|
-
|
|
354
|
-
# 指定前缀
|
|
355
|
-
gw t v
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
**自动检测前缀:**
|
|
359
|
-
|
|
360
|
-
工具会自动检测仓库中已有的 tag 前缀,并智能推荐:
|
|
361
|
-
|
|
362
|
-
```bash
|
|
363
|
-
gw t
|
|
364
|
-
# 检测到以下 tag 前缀:
|
|
365
|
-
# ? 选择 tag 前缀:
|
|
366
|
-
# ❯ v (最新: v1.2.0)
|
|
367
|
-
# release- (最新: release-1.0.0)
|
|
368
|
-
# + 使用新前缀
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
如果仓库没有任何 tag,会引导创建初始版本:
|
|
372
|
-
|
|
373
|
-
```bash
|
|
374
|
-
gw t
|
|
375
|
-
# 当前仓库没有 tag,请输入前缀 (如 v): v
|
|
376
|
-
# ? 选择初始版本号:
|
|
377
|
-
# v0.0.1
|
|
378
|
-
# v0.1.0
|
|
379
|
-
# v1.0.0
|
|
380
|
-
# 自定义...
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
支持的版本类型:
|
|
384
|
-
|
|
385
|
-
| 当前版本 | 可选操作 |
|
|
386
|
-
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
387
|
-
| `v1.2.3` | patch → `v1.2.4`<br>minor → `v1.3.0`<br>major → `v2.0.0`<br>alpha → `v1.2.4-alpha.1`<br>beta → `v1.2.4-beta.1`<br>rc → `v1.2.4-rc.1` |
|
|
388
|
-
| `v1.2.4-beta.1` | pre → `v1.2.4-beta.2`<br>release → `v1.2.4`<br>patch/minor/major... |
|
|
389
|
-
|
|
390
|
-
#### 删除 Tag
|
|
391
|
-
|
|
392
|
-
```bash
|
|
393
|
-
# 交互式选择要删除的 tag
|
|
394
|
-
gw td
|
|
395
|
-
|
|
396
|
-
# 示例流程
|
|
397
|
-
? 选择要删除的 tag:
|
|
398
|
-
❯ v1.2.0 (2 days ago)
|
|
399
|
-
v1.1.0 (1 week ago)
|
|
400
|
-
v1.0.0 (2 weeks ago)
|
|
401
|
-
|
|
402
|
-
? 确认删除 tag v1.2.0?
|
|
403
|
-
❯ 是,删除本地和远程
|
|
404
|
-
仅删除本地
|
|
405
|
-
取消
|
|
406
|
-
|
|
407
|
-
✔ 本地 tag 已删除: v1.2.0
|
|
408
|
-
✔ 远程 tag 已删除: origin/v1.2.0
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
#### 修改 Tag
|
|
412
|
-
|
|
413
|
-
```bash
|
|
414
|
-
# 交互式选择要修改的 tag
|
|
415
|
-
gw tu
|
|
416
|
-
|
|
417
|
-
# 示例流程
|
|
418
|
-
? 选择要修改的 tag:
|
|
419
|
-
❯ v1.2.0 Release v1.2.0 (2 days ago)
|
|
420
|
-
v1.1.0 Release v1.1.0 (1 week ago)
|
|
421
|
-
|
|
422
|
-
当前消息: Release v1.2.0
|
|
423
|
-
? 输入新的 tag 消息: Release v1.2.0 - Bug fixes
|
|
424
|
-
|
|
425
|
-
✔ Tag 消息已更新: v1.2.0
|
|
426
|
-
✔ 已推送到远程
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
### 📦 版本命令
|
|
430
|
-
|
|
431
|
-
| 命令 | 别名 | 说明 |
|
|
432
|
-
| ------------ | ------ | ----------------------------------- |
|
|
433
|
-
| `gw release` | `gw r` | 交互式选择版本号并更新 package.json |
|
|
434
|
-
|
|
435
|
-
```bash
|
|
436
|
-
gw r
|
|
437
|
-
# 当前版本: 0.0.1
|
|
438
|
-
# ? 选择新版本:
|
|
439
|
-
# patch → 0.0.2
|
|
440
|
-
# minor → 0.1.0
|
|
441
|
-
# major → 1.0.0
|
|
442
|
-
# alpha → 0.0.2-alpha.1
|
|
443
|
-
# beta → 0.0.2-beta.1
|
|
444
|
-
# rc → 0.0.2-rc.1
|
|
445
|
-
# ✓ 版本号已更新: 0.0.1 → 0.0.2
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
### ⚙️ 配置命令
|
|
449
|
-
|
|
450
|
-
| 命令 | 说明 |
|
|
451
|
-
| --------- | ------------------------------------------------ |
|
|
452
|
-
| `gw init` | 交互式初始化配置文件(可选择全局配置或项目配置) |
|
|
453
|
-
|
|
454
|
-
### 🔄 更新命令
|
|
455
|
-
|
|
456
|
-
| 命令 | 别名 | 说明 |
|
|
457
|
-
| ----------- | -------- | -------------------- |
|
|
458
|
-
| `gw update` | `gw upt` | 检查并更新到最新版本 |
|
|
459
|
-
|
|
460
|
-
```bash
|
|
461
|
-
# 创建全局配置(推荐,一次配置所有项目生效)
|
|
462
|
-
gw init
|
|
463
|
-
# 选择 "全局配置(所有项目生效)"
|
|
464
|
-
# 配置保存到 ~/.gwrc.json
|
|
465
|
-
|
|
466
|
-
# 创建项目配置(仅当前项目生效)
|
|
467
|
-
gw init
|
|
468
|
-
# 选择 "项目配置(仅当前项目)"
|
|
469
|
-
# 配置保存到 .gwrc.json
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
#### 更新命令
|
|
473
|
-
|
|
474
|
-
```bash
|
|
475
|
-
# 检查并更新到最新版本
|
|
476
|
-
gw update
|
|
477
|
-
|
|
478
|
-
# 或使用别名
|
|
479
|
-
gw upt
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
**更新流程:**
|
|
483
|
-
|
|
484
|
-
```bash
|
|
485
|
-
gw update
|
|
486
|
-
|
|
487
|
-
🔍 检查更新...
|
|
488
|
-
|
|
489
|
-
┌─────────────────────────────────┐
|
|
490
|
-
│ │
|
|
491
|
-
│ 🎉 发现新版本! │
|
|
492
|
-
│ │
|
|
493
|
-
│ 0.2.16 → 0.2.17 │
|
|
494
|
-
│ │
|
|
495
|
-
└─────────────────────────────────┘
|
|
496
|
-
|
|
497
|
-
✔ 更新成功!
|
|
498
|
-
|
|
499
|
-
┌─────────────────────────────────┐
|
|
500
|
-
│ │
|
|
501
|
-
│ ✨ 更新完成! │
|
|
502
|
-
│ │
|
|
503
|
-
│ 请重新打开终端使用新版本 │
|
|
504
|
-
│ │
|
|
505
|
-
└─────────────────────────────────┘
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
**说明:**
|
|
509
|
-
|
|
510
|
-
- 自动检测最新版本
|
|
511
|
-
- 如果已是最新版本,显示提示
|
|
512
|
-
- 如果有新版本,自动更新
|
|
513
|
-
- 更新成功后提示重新打开终端
|
|
514
|
-
|
|
515
|
-
**配置流程:**
|
|
516
|
-
|
|
517
|
-
```bash
|
|
518
|
-
gw init
|
|
519
|
-
|
|
520
|
-
⚙️ 初始化 git-workflow 配置
|
|
521
|
-
|
|
522
|
-
? 选择配置范围:
|
|
523
|
-
❯ 全局配置(所有项目生效) # 推荐!配置一次,所有项目都能用
|
|
524
|
-
项目配置(仅当前项目) # 为特定项目自定义配置
|
|
525
|
-
|
|
526
|
-
# 然后按提示配置各项参数
|
|
527
|
-
# 包括:分支前缀、ID 要求、自动推送、AI commit 等
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
### 💾 Stash 命令
|
|
531
|
-
|
|
532
|
-
| 命令 | 别名 | 说明 |
|
|
533
|
-
| ---------- | --------------- | ---------------- |
|
|
534
|
-
| `gw stash` | `gw s`, `gw st` | 交互式管理 stash |
|
|
535
|
-
|
|
536
|
-
原生 `git stash list` 输出难以阅读,`gw stash` 提供清晰的交互式界面:
|
|
537
|
-
|
|
538
|
-
```bash
|
|
539
|
-
gw st
|
|
540
|
-
# 共 3 个 stash:
|
|
541
|
-
#
|
|
542
|
-
# ? 选择 stash:
|
|
543
|
-
# [0] main fix login bug (3 文件) 2 hours ago
|
|
544
|
-
# [1] develop add new feature (5 文件) 1 day ago
|
|
545
|
-
# [2] main WIP (1 文件) 3 days ago
|
|
546
|
-
# + 创建新 stash
|
|
547
|
-
# 取消
|
|
548
|
-
```
|
|
549
|
-
|
|
550
|
-
选择后显示详情并提供操作:
|
|
551
|
-
|
|
552
|
-
```bash
|
|
553
|
-
# Stash #0
|
|
554
|
-
# 分支: main
|
|
555
|
-
# 消息: fix login bug
|
|
556
|
-
# 时间: 2 hours ago
|
|
557
|
-
# 文件 (3):
|
|
558
|
-
# • src/auth.ts
|
|
559
|
-
# • src/login.ts
|
|
560
|
-
# • tests/auth.test.ts
|
|
561
|
-
# ────────────────────────────────────────
|
|
562
|
-
# ? 操作:
|
|
563
|
-
# 应用 (保留 stash)
|
|
564
|
-
# 弹出 (应用并删除)
|
|
565
|
-
# 创建分支 <- 复用 feature/hotfix 命名规范
|
|
566
|
-
# 查看差异 <- 查看后返回菜单
|
|
567
|
-
# 删除
|
|
568
|
-
# 返回列表
|
|
569
|
-
# 取消
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
创建 stash 时,如果检测到未跟踪的新文件,会询问是否一并 stash。
|
|
573
|
-
|
|
574
|
-
### 📝 Commit 命令
|
|
575
|
-
|
|
576
|
-
| 命令 | 别名 | 说明 |
|
|
577
|
-
| ----------- | --------------- | ------------------------------------------- |
|
|
578
|
-
| `gw commit` | `gw c`, `gw cm` | 交互式提交 (Conventional Commits + Gitmoji) |
|
|
579
|
-
|
|
580
|
-
遵循 [Conventional Commits](https://www.conventionalcommits.org/zh-hans/) 规范,并自动添加 [Gitmoji](https://gitmoji.dev/) 表情:
|
|
581
|
-
|
|
582
|
-
#### 🤖 AI 自动生成(推荐)
|
|
583
|
-
|
|
584
|
-
使用 AI 自动分析代码变更生成 commit message:
|
|
585
|
-
|
|
586
|
-
```bash
|
|
587
|
-
gw c
|
|
588
|
-
# 已暂存的文件:
|
|
589
|
-
# src/ai-service.ts
|
|
590
|
-
# src/commands/commit.ts
|
|
591
|
-
# ────────────────────────────────────────
|
|
592
|
-
# ? 选择 commit 方式:
|
|
593
|
-
# ❯ 🤖 AI 自动生成 commit message
|
|
594
|
-
# ✍️ 手动编写 commit message
|
|
595
|
-
#
|
|
596
|
-
# ✔ AI 生成完成
|
|
597
|
-
#
|
|
598
|
-
# AI 生成的 commit message:
|
|
599
|
-
# feat(ai): 添加 AI commit message 自动生成功能
|
|
600
|
-
# ────────────────────────────────────────
|
|
601
|
-
# ? 使用这个 commit message?
|
|
602
|
-
# ❯ ✅ 使用
|
|
603
|
-
# ❌ 不使用,切换到手动模式
|
|
604
183
|
```
|
|
605
184
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
- ⚡️ 快速:2-3 秒生成
|
|
609
|
-
- 🎯 准确:自动识别 feat/fix/docs 等类型
|
|
610
|
-
- 📝 规范:符合 Conventional Commits
|
|
611
|
-
- 🇨🇳 支持中英文
|
|
612
|
-
- 🔄 可预览、可拒绝、可降级到手动模式
|
|
185
|
+
## 📚 完整文档
|
|
613
186
|
|
|
614
|
-
|
|
187
|
+
想了解更多功能和用法?查看我们的完整文档:
|
|
615
188
|
|
|
616
|
-
- **
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
- **
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
- **
|
|
624
|
-
|
|
625
|
-
- 获取地址:https://console.anthropic.com/
|
|
626
|
-
- **Ollama**(本地)
|
|
627
|
-
- 需要安装 Ollama,无需 API key
|
|
628
|
-
- 安装地址:https://ollama.com/
|
|
189
|
+
- 📖 **[完整文档](https://iamzjt-front-end.github.io/git-workflow/)** - 详细的功能介绍和使用指南
|
|
190
|
+
- 🚀 **[快速开始](https://iamzjt-front-end.github.io/git-workflow/guide/getting-started)** - 5 分钟上手指南
|
|
191
|
+
- 📋 **[命令参考](https://iamzjt-front-end.github.io/git-workflow/commands/)** - 所有命令的详细说明
|
|
192
|
+
- ⚙️ **[配置指南](https://iamzjt-front-end.github.io/git-workflow/config/)** - 配置文件详解和最佳实践
|
|
193
|
+
- 🤖 **[AI 配置](https://iamzjt-front-end.github.io/git-workflow/config/ai-config)** - AI 提供商配置指南
|
|
194
|
+
- 🌿 **[分支管理](https://iamzjt-front-end.github.io/git-workflow/guide/branch-management)** - 分支命名规范和管理技巧
|
|
195
|
+
- 🏷️ **[Tag 管理](https://iamzjt-front-end.github.io/git-workflow/guide/tag-management)** - 版本标签管理和语义化版本
|
|
196
|
+
- 💾 **[Stash 管理](https://iamzjt-front-end.github.io/git-workflow/guide/stash-management)** - 可视化 stash 操作指南
|
|
197
|
+
- 👥 **[团队协作](https://iamzjt-front-end.github.io/git-workflow/guide/team-collaboration)** - 团队配置和最佳实践
|
|
629
198
|
|
|
630
|
-
|
|
199
|
+
## 🛠️ 开发与贡献
|
|
631
200
|
|
|
632
|
-
|
|
633
|
-
gw c
|
|
634
|
-
# 已暂存的文件:
|
|
635
|
-
# src/index.ts
|
|
636
|
-
# src/utils.ts
|
|
637
|
-
# ────────────────────────────────────────
|
|
638
|
-
# ? 选择 commit 方式:
|
|
639
|
-
# 🤖 AI 自动生成 commit message
|
|
640
|
-
# ❯ ✍️ 手动编写 commit message
|
|
641
|
-
#
|
|
642
|
-
# ? 选择提交类型:
|
|
643
|
-
# ✨ feat 新功能
|
|
644
|
-
# 🐛 fix 修复 Bug
|
|
645
|
-
# 📝 docs 文档更新
|
|
646
|
-
# 💄 style 代码格式 (不影响功能)
|
|
647
|
-
# ♻️ refactor 重构 (非新功能/修复)
|
|
648
|
-
# ⚡️ perf 性能优化
|
|
649
|
-
# ✅ test 测试相关
|
|
650
|
-
# 📦 build 构建/依赖相关
|
|
651
|
-
# 👷 ci CI/CD 相关
|
|
652
|
-
# 🔧 chore 其他杂项
|
|
653
|
-
# ⏪ revert 回退提交
|
|
654
|
-
# ? 输入影响范围 scope (可跳过): auth
|
|
655
|
-
# ? 输入简短描述: add login validation
|
|
656
|
-
# ? 输入详细描述 (可跳过):
|
|
657
|
-
# ? 是否包含破坏性变更 (BREAKING CHANGE)?
|
|
658
|
-
# ❯ 否
|
|
659
|
-
# 是
|
|
660
|
-
# ? 关联 Issue (如 #123, 可跳过): #42
|
|
661
|
-
# ────────────────────────────────────────
|
|
662
|
-
# 提交信息预览:
|
|
663
|
-
# ✨ feat(auth): add login validation
|
|
664
|
-
#
|
|
665
|
-
# #42
|
|
666
|
-
# ────────────────────────────────────────
|
|
667
|
-
# ? 确认提交?
|
|
668
|
-
# ❯ ✅ 确认提交
|
|
669
|
-
# ❌ 取消
|
|
670
|
-
# ✔ 提交成功
|
|
671
|
-
# commit: a1b2c3d
|
|
672
|
-
```
|
|
201
|
+
想要参与开发或了解更多技术细节?查看我们的开发文档:
|
|
673
202
|
|
|
674
|
-
|
|
203
|
+
- 🔧 **[开发指南](https://iamzjt-front-end.github.io/git-workflow/guide/development)** - 本地开发环境搭建
|
|
204
|
+
- 🧪 **[测试指南](https://iamzjt-front-end.github.io/git-workflow/guide/testing)** - 测试框架和覆盖率
|
|
205
|
+
- 📋 **[API 文档](https://iamzjt-front-end.github.io/git-workflow/api/)** - 内部 API 参考
|
|
206
|
+
- 🤝 **[贡献指南](https://iamzjt-front-end.github.io/git-workflow/guide/contributing)** - 如何参与贡献
|
|
675
207
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
**默认行为(`autoStage: true`):**
|
|
679
|
-
|
|
680
|
-
```bash
|
|
681
|
-
gw c
|
|
682
|
-
# 没有暂存的更改
|
|
683
|
-
# ────────────────────────────────────────
|
|
684
|
-
# 未暂存的文件:
|
|
685
|
-
# M src/index.ts
|
|
686
|
-
# M src/utils.ts
|
|
687
|
-
# ────────────────────────────────────────
|
|
688
|
-
# ✔ 已自动暂存所有更改
|
|
689
|
-
```
|
|
690
|
-
|
|
691
|
-
**手动选择文件(`autoStage: false`):**
|
|
692
|
-
|
|
693
|
-
```bash
|
|
694
|
-
gw c
|
|
695
|
-
# 没有暂存的更改
|
|
696
|
-
# ────────────────────────────────────────
|
|
697
|
-
# 未暂存的文件:
|
|
698
|
-
# M src/index.ts
|
|
699
|
-
# M src/utils.ts
|
|
700
|
-
# ────────────────────────────────────────
|
|
701
|
-
# ? 选择要暂存的文件: (使用空格选择)
|
|
702
|
-
# ◉ M src/index.ts
|
|
703
|
-
# ◉ M src/utils.ts
|
|
704
|
-
# ✔ 已暂存 2 个文件
|
|
705
|
-
```
|
|
706
|
-
|
|
707
|
-
## ⚙️ 配置文件
|
|
708
|
-
|
|
709
|
-
git-workflow 支持两种配置方式:
|
|
710
|
-
|
|
711
|
-
### 配置优先级
|
|
712
|
-
|
|
713
|
-
1. **项目配置**(`.gwrc.json` / `.gwrc` / `gw.config.json`)- 仅当前项目生效
|
|
714
|
-
2. **全局配置**(`~/.gwrc.json`)- 所有项目生效
|
|
715
|
-
3. **默认配置** - 内置默认值
|
|
716
|
-
|
|
717
|
-
**配置合并规则:** 项目配置 > 全局配置 > 默认配置
|
|
718
|
-
|
|
719
|
-
### 快速开始
|
|
720
|
-
|
|
721
|
-
```bash
|
|
722
|
-
# 创建全局配置(推荐)
|
|
723
|
-
gw init
|
|
724
|
-
# 选择 "全局配置(所有项目生效)"
|
|
725
|
-
# 配置一次,所有项目都能使用 AI commit 等功能
|
|
726
|
-
|
|
727
|
-
# 为特定项目创建自定义配置
|
|
728
|
-
cd your-project
|
|
729
|
-
gw init
|
|
730
|
-
# 选择 "项目配置(仅当前项目)"
|
|
731
|
-
# 项目配置会覆盖全局配置
|
|
732
|
-
```
|
|
733
|
-
|
|
734
|
-
### 配置文件位置
|
|
735
|
-
|
|
736
|
-
| 类型 | 位置 | 说明 |
|
|
737
|
-
| -------- | ----------------------------------------- | ------------------------------------ |
|
|
738
|
-
| 全局配置 | `~/.gwrc.json` | 对所有项目生效,无需在每个项目中配置 |
|
|
739
|
-
| 项目配置 | `.gwrc.json` / `.gwrc` / `gw.config.json` | 仅当前项目生效,可覆盖全局配置 |
|
|
740
|
-
|
|
741
|
-
**查找顺序:** 当前目录 → Git 仓库根目录 → 用户主目录
|
|
742
|
-
|
|
743
|
-
### 使用场景
|
|
744
|
-
|
|
745
|
-
**全局配置适合:**
|
|
746
|
-
|
|
747
|
-
- AI commit 配置(API key、提供商等)
|
|
748
|
-
- 个人习惯配置(emoji、自动暂存等)
|
|
749
|
-
- 通用的分支命名规范
|
|
750
|
-
|
|
751
|
-
**项目配置适合:**
|
|
752
|
-
|
|
753
|
-
- 团队统一的分支规范
|
|
754
|
-
- 项目特定的 ID 要求
|
|
755
|
-
- 特殊的分支前缀
|
|
756
|
-
|
|
757
|
-
### 完整配置示例
|
|
758
|
-
|
|
759
|
-
```json
|
|
760
|
-
{
|
|
761
|
-
"baseBranch": "develop",
|
|
762
|
-
"featurePrefix": "feature",
|
|
763
|
-
"hotfixPrefix": "hotfix",
|
|
764
|
-
"requireId": true,
|
|
765
|
-
"featureIdLabel": "Story ID",
|
|
766
|
-
"hotfixIdLabel": "Issue ID",
|
|
767
|
-
"defaultTagPrefix": "v",
|
|
768
|
-
"autoPush": true,
|
|
769
|
-
"autoStage": true,
|
|
770
|
-
"useEmoji": true,
|
|
771
|
-
"aiCommit": {
|
|
772
|
-
"enabled": true,
|
|
773
|
-
"provider": "github",
|
|
774
|
-
"apiKey": "",
|
|
775
|
-
"model": "gpt-4o-mini",
|
|
776
|
-
"language": "zh-CN",
|
|
777
|
-
"maxTokens": 200
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
### 配置项说明
|
|
783
|
-
|
|
784
|
-
| 配置项 | 类型 | 默认值 | 说明 |
|
|
785
|
-
| ------------------ | --------- | ------------ | ------------------------------------------------------------------------------- |
|
|
786
|
-
| `baseBranch` | `string` | 自动检测 | 默认基础分支,不设置则自动检测 main/master |
|
|
787
|
-
| `featurePrefix` | `string` | `"feature"` | feature 分支前缀 |
|
|
788
|
-
| `hotfixPrefix` | `string` | `"hotfix"` | hotfix 分支前缀 |
|
|
789
|
-
| `requireId` | `boolean` | `false` | 是否强制要求填写 ID(Story ID/Issue ID)。开启后创建分支时必须填写 ID,不能跳过 |
|
|
790
|
-
| `featureIdLabel` | `string` | `"Story ID"` | feature 分支 ID 提示文字 |
|
|
791
|
-
| `hotfixIdLabel` | `string` | `"Issue ID"` | hotfix 分支 ID 提示文字 |
|
|
792
|
-
| `defaultTagPrefix` | `string` | - | 默认 tag 前缀,设置后跳过选择步骤 |
|
|
793
|
-
| `autoPush` | `boolean` | - | 创建分支后是否自动推送到远程。`true` 自动推送,`false` 不推送,不设置则每次询问 |
|
|
794
|
-
| `autoStage` | `boolean` | `true` | commit 时是否自动暂存所有更改 |
|
|
795
|
-
| `useEmoji` | `boolean` | `true` | commit 时是否使用 emoji |
|
|
796
|
-
| `commitEmojis` | `object` | - | 自定义各类型 commit 的 emoji |
|
|
797
|
-
| `aiCommit` | `object` | - | AI commit 配置 |
|
|
798
|
-
|
|
799
|
-
#### AI Commit 配置项
|
|
800
|
-
|
|
801
|
-
| 配置项 | 类型 | 默认值 | 说明 |
|
|
802
|
-
| -------------------- | --------- | ---------- | ---------------------------------------------------- |
|
|
803
|
-
| `aiCommit.enabled` | `boolean` | `true` | 是否启用 AI commit 功能 |
|
|
804
|
-
| `aiCommit.provider` | `string` | `"github"` | AI 提供商:`github` / `openai` / `claude` / `ollama` |
|
|
805
|
-
| `aiCommit.apiKey` | `string` | - | API key,留空使用内置 key |
|
|
806
|
-
| `aiCommit.model` | `string` | 根据提供商 | 模型名称 |
|
|
807
|
-
| `aiCommit.language` | `string` | `"zh-CN"` | 生成语言:`zh-CN` / `en-US` |
|
|
808
|
-
| `aiCommit.maxTokens` | `number` | `200` | 最大 token 数 |
|
|
809
|
-
|
|
810
|
-
### 常见配置场景
|
|
811
|
-
|
|
812
|
-
<details>
|
|
813
|
-
<summary><b>场景一:全局启用 AI Commit(强烈推荐)</b></summary>
|
|
814
|
-
|
|
815
|
-
**一次配置,所有项目生效!**
|
|
816
|
-
|
|
817
|
-
```bash
|
|
818
|
-
# 1. 创建全局配置
|
|
819
|
-
gw init
|
|
820
|
-
# 选择 "全局配置(所有项目生效)"
|
|
821
|
-
|
|
822
|
-
# 2. 配置 AI commit
|
|
823
|
-
# 选择 AI 提供商: GitHub Models(免费,推荐)
|
|
824
|
-
#
|
|
825
|
-
# 💡 如何获取 GitHub Token:
|
|
826
|
-
# 1. 访问: https://github.com/settings/tokens/new
|
|
827
|
-
# 2. 勾选 'repo' 权限
|
|
828
|
-
# 3. 生成并复制 token
|
|
829
|
-
#
|
|
830
|
-
# 输入你的 GitHub Token: ghp_xxxxxxxxxxxx
|
|
831
|
-
# 选择语言: 中文
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
生成的全局配置文件 `~/.gwrc.json`:
|
|
835
|
-
|
|
836
|
-
```json
|
|
837
|
-
{
|
|
838
|
-
"featurePrefix": "feature",
|
|
839
|
-
"hotfixPrefix": "hotfix",
|
|
840
|
-
"requireId": false,
|
|
841
|
-
"featureIdLabel": "Story ID",
|
|
842
|
-
"hotfixIdLabel": "Issue ID",
|
|
843
|
-
"autoStage": true,
|
|
844
|
-
"useEmoji": true,
|
|
845
|
-
"aiCommit": {
|
|
846
|
-
"enabled": true,
|
|
847
|
-
"provider": "github",
|
|
848
|
-
"language": "zh-CN",
|
|
849
|
-
"model": "gpt-4o-mini"
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
**效果:**
|
|
855
|
-
|
|
856
|
-
- ✅ 所有项目都能使用 AI commit
|
|
857
|
-
- ✅ 无需在每个项目中重复配置
|
|
858
|
-
- ✅ 新项目自动继承配置
|
|
859
|
-
- ✅ 独享 GitHub Models 限额(每天 150 次)
|
|
860
|
-
|
|
861
|
-
**GitHub Token 权限说明:**
|
|
862
|
-
|
|
863
|
-
- 只需要勾选 `repo` 权限
|
|
864
|
-
- Token 仅用于调用 GitHub Models API
|
|
865
|
-
- 不会访问你的代码仓库
|
|
866
|
-
|
|
867
|
-
**手动编辑配置文件:**
|
|
868
|
-
|
|
869
|
-
```json
|
|
870
|
-
{
|
|
871
|
-
"aiCommit": {
|
|
872
|
-
"enabled": true,
|
|
873
|
-
"provider": "github",
|
|
874
|
-
"apiKey": "ghp_your_token_here",
|
|
875
|
-
"language": "zh-CN"
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
```
|
|
879
|
-
|
|
880
|
-
获取 GitHub Token:https://github.com/settings/tokens/new
|
|
881
|
-
|
|
882
|
-
</details>
|
|
883
|
-
|
|
884
|
-
<details>
|
|
885
|
-
<summary><b>场景二:团队项目配置(覆盖全局配置)</b></summary>
|
|
886
|
-
|
|
887
|
-
**全局配置 + 项目配置 = 灵活组合**
|
|
888
|
-
|
|
889
|
-
假设你已经有全局配置(启用了 AI commit),现在要为团队项目添加特定规范:
|
|
890
|
-
|
|
891
|
-
```bash
|
|
892
|
-
cd team-project
|
|
893
|
-
gw init
|
|
894
|
-
# 选择 "项目配置(仅当前项目)"
|
|
895
|
-
```
|
|
896
|
-
|
|
897
|
-
项目配置 `.gwrc.json`:
|
|
898
|
-
|
|
899
|
-
```json
|
|
900
|
-
{
|
|
901
|
-
"requireId": true,
|
|
902
|
-
"featureIdLabel": "Jira ID",
|
|
903
|
-
"hotfixIdLabel": "Bug ID",
|
|
904
|
-
"autoPush": true,
|
|
905
|
-
"baseBranch": "develop"
|
|
906
|
-
}
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
**最终生效的配置:**
|
|
910
|
-
|
|
911
|
-
- ✅ AI commit 配置来自全局配置
|
|
912
|
-
- ✅ 分支规范来自项目配置
|
|
913
|
-
- ✅ 项目配置覆盖全局配置的同名字段
|
|
914
|
-
|
|
915
|
-
**提交到仓库:**
|
|
916
|
-
|
|
917
|
-
```bash
|
|
918
|
-
git add .gwrc.json
|
|
919
|
-
git commit -m "chore: add git-workflow config"
|
|
920
|
-
```
|
|
921
|
-
|
|
922
|
-
团队成员拉取代码后,自动使用统一的分支规范,同时保留各自的 AI commit 配置。
|
|
923
|
-
|
|
924
|
-
</details>
|
|
925
|
-
|
|
926
|
-
<details>
|
|
927
|
-
<summary><b>场景三:强制关联 Issue/Story(适合团队协作)</b></summary>
|
|
928
|
-
|
|
929
|
-
```json
|
|
930
|
-
{
|
|
931
|
-
"requireId": true,
|
|
932
|
-
"featureIdLabel": "Jira ID",
|
|
933
|
-
"hotfixIdLabel": "Bug ID"
|
|
934
|
-
}
|
|
935
|
-
```
|
|
936
|
-
|
|
937
|
-
**说明:**
|
|
938
|
-
|
|
939
|
-
- `requireId: true` - 创建分支时必须填写 ID,不能跳过
|
|
940
|
-
- 确保每个分支都能追溯到具体的需求或 Bug
|
|
941
|
-
- 适合使用 Jira、禅道等项目管理工具的团队
|
|
942
|
-
|
|
943
|
-
**效果对比:**
|
|
944
|
-
|
|
945
|
-
```bash
|
|
946
|
-
# requireId: false(默认)
|
|
947
|
-
gw f
|
|
948
|
-
? 请输入 Story ID (可跳过): # 可以直接回车跳过
|
|
949
|
-
? 请输入描述: add-login
|
|
950
|
-
✔ 分支创建成功: feature/20260109-add-login
|
|
951
|
-
|
|
952
|
-
# requireId: true
|
|
953
|
-
gw f
|
|
954
|
-
? 请输入 Jira ID: # 必须填写,不能跳过
|
|
955
|
-
? 请输入描述: add-login
|
|
956
|
-
✔ 分支创建成功: feature/20260109-PROJ-123-add-login
|
|
957
|
-
```
|
|
958
|
-
|
|
959
|
-
</details>
|
|
960
|
-
|
|
961
|
-
<details>
|
|
962
|
-
<summary><b>场景四:自动推送到远程(提高效率)</b></summary>
|
|
963
|
-
|
|
964
|
-
```json
|
|
965
|
-
{
|
|
966
|
-
"autoPush": true
|
|
967
|
-
}
|
|
968
|
-
```
|
|
969
|
-
|
|
970
|
-
**说明:**
|
|
971
|
-
|
|
972
|
-
- `autoPush: true` - 创建分支后自动推送到远程,不再询问
|
|
973
|
-
- `autoPush: false` - 创建分支后不推送,不再询问
|
|
974
|
-
- 不设置 - 每次创建分支时询问是否推送(默认行为)
|
|
975
|
-
|
|
976
|
-
**效果对比:**
|
|
977
|
-
|
|
978
|
-
```bash
|
|
979
|
-
# autoPush 未设置(默认)
|
|
980
|
-
gw f
|
|
981
|
-
✔ 分支创建成功: feature/20260109-add-login
|
|
982
|
-
? 是否推送到远程? # 每次都会询问
|
|
983
|
-
是
|
|
984
|
-
否
|
|
985
|
-
|
|
986
|
-
# autoPush: true
|
|
987
|
-
gw f
|
|
988
|
-
✔ 分支创建成功: feature/20260109-add-login
|
|
989
|
-
(自动推送已启用) # 直接推送,不询问
|
|
990
|
-
✔ 已推送到远程: origin/feature/20260109-add-login
|
|
991
|
-
|
|
992
|
-
# autoPush: false
|
|
993
|
-
gw f
|
|
994
|
-
✔ 分支创建成功: feature/20260109-add-login
|
|
995
|
-
# 不推送,不询问
|
|
996
|
-
```
|
|
997
|
-
|
|
998
|
-
**适用场景:**
|
|
999
|
-
|
|
1000
|
-
- `true` - 团队协作,需要及时同步分支
|
|
1001
|
-
- `false` - 个人开发,暂时不想推送
|
|
1002
|
-
- 不设置 - 灵活决定,根据情况选择
|
|
1003
|
-
|
|
1004
|
-
</details>
|
|
1005
|
-
|
|
1006
|
-
<details>
|
|
1007
|
-
<summary><b>场景五:基于 develop 分支开发</b></summary>
|
|
1008
|
-
|
|
1009
|
-
```json
|
|
1010
|
-
{
|
|
1011
|
-
"baseBranch": "develop",
|
|
1012
|
-
"autoPush": true,
|
|
1013
|
-
"requireId": true
|
|
1014
|
-
}
|
|
1015
|
-
```
|
|
1016
|
-
|
|
1017
|
-
**说明:**
|
|
1018
|
-
|
|
1019
|
-
- 所有新分支都基于 `develop` 创建
|
|
1020
|
-
- 自动推送到远程
|
|
1021
|
-
- 强制要求填写 ID
|
|
1022
|
-
|
|
1023
|
-
</details>
|
|
1024
|
-
|
|
1025
|
-
<details>
|
|
1026
|
-
<summary><b>场景六:自定义分支前缀</b></summary>
|
|
1027
|
-
|
|
1028
|
-
```json
|
|
1029
|
-
{
|
|
1030
|
-
"featurePrefix": "feat",
|
|
1031
|
-
"hotfixPrefix": "fix"
|
|
1032
|
-
}
|
|
1033
|
-
```
|
|
1034
|
-
|
|
1035
|
-
**说明:**
|
|
1036
|
-
|
|
1037
|
-
- 分支名变为 `feat/20260109-xxx` 和 `fix/20260109-xxx`
|
|
1038
|
-
- 适合有特定命名规范的团队
|
|
1039
|
-
|
|
1040
|
-
</details>
|
|
1041
|
-
|
|
1042
|
-
<details>
|
|
1043
|
-
<summary><b>场景七:禁用 Emoji(适合严格的 CI/CD 环境)</b></summary>
|
|
1044
|
-
|
|
1045
|
-
```json
|
|
1046
|
-
{
|
|
1047
|
-
"useEmoji": false,
|
|
1048
|
-
"autoStage": false
|
|
1049
|
-
}
|
|
1050
|
-
```
|
|
1051
|
-
|
|
1052
|
-
**说明:**
|
|
1053
|
-
|
|
1054
|
-
- 提交信息格式变为:`feat(scope): description` 而不是 `✨ feat(scope): description`
|
|
1055
|
-
- 手动选择要暂存的文件,而不是自动暂存所有更改
|
|
1056
|
-
|
|
1057
|
-
</details>
|
|
1058
|
-
|
|
1059
|
-
<details>
|
|
1060
|
-
<summary><b>场景八:自定义 Commit Emoji</b></summary>
|
|
1061
|
-
|
|
1062
|
-
```json
|
|
1063
|
-
{
|
|
1064
|
-
"commitEmojis": {
|
|
1065
|
-
"feat": "🎉",
|
|
1066
|
-
"fix": "🔧",
|
|
1067
|
-
"docs": "📚",
|
|
1068
|
-
"style": "🎨",
|
|
1069
|
-
"refactor": "🔨",
|
|
1070
|
-
"perf": "🚀",
|
|
1071
|
-
"test": "🧪",
|
|
1072
|
-
"build": "📦",
|
|
1073
|
-
"ci": "👷",
|
|
1074
|
-
"chore": "🔧",
|
|
1075
|
-
"revert": "⏪"
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
```
|
|
1079
|
-
|
|
1080
|
-
**说明:**
|
|
1081
|
-
|
|
1082
|
-
- 可以只覆盖部分类型,未配置的使用默认 emoji
|
|
1083
|
-
|
|
1084
|
-
</details>
|
|
1085
|
-
|
|
1086
|
-
## 💡 最佳实践
|
|
1087
|
-
|
|
1088
|
-
### 团队协作
|
|
1089
|
-
|
|
1090
|
-
1. **统一配置** - 将 `.gwrc.json` 提交到仓库,确保团队使用相同的分支规范
|
|
1091
|
-
2. **强制 ID** - 开启 `requireId`,确保每个分支都能追溯到需求/Issue
|
|
1092
|
-
3. **自动推送** - 开启 `autoPush`,减少遗忘推送的情况
|
|
1093
|
-
4. **启用 AI Commit** - 配置 AI 提供商,让团队提交信息更规范统一
|
|
1094
|
-
|
|
1095
|
-
### 版本发布
|
|
1096
|
-
|
|
1097
|
-
1. **预发布测试** - 使用 alpha/beta/rc 版本进行测试
|
|
1098
|
-
2. **语义化版本** - 遵循 semver 规范:
|
|
1099
|
-
- Bug 修复用 `patch`(1.0.0 → 1.0.1)
|
|
1100
|
-
- 新功能用 `minor`(1.0.0 → 1.1.0)
|
|
1101
|
-
- 破坏性变更用 `major`(1.0.0 → 2.0.0)
|
|
1102
|
-
3. **Tag 与版本同步** - 发布版本后立即创建对应的 tag
|
|
1103
|
-
|
|
1104
|
-
### 分支清理
|
|
1105
|
-
|
|
1106
|
-
1. **定期清理** - 使用 `gw d` 定期清理已合并的分支
|
|
1107
|
-
2. **远程同步** - 删除分支时同时清理远程分支
|
|
1108
|
-
3. **保持整洁** - 避免积累过多无用分支
|
|
1109
|
-
|
|
1110
|
-
### Stash 管理
|
|
1111
|
-
|
|
1112
|
-
1. **及时命名** - 创建 stash 时添加清晰的描述
|
|
1113
|
-
2. **定期清理** - 不再需要的 stash 及时删除
|
|
1114
|
-
3. **创建分支** - 对于长期保留的改动,考虑创建分支而不是 stash
|
|
1115
|
-
|
|
1116
|
-
### Commit 规范
|
|
1117
|
-
|
|
1118
|
-
1. **优先使用 AI** - AI 生成的 commit message 更规范、更准确
|
|
1119
|
-
2. **添加 scope** - 明确改动的模块或功能范围
|
|
1120
|
-
3. **关联 Issue** - 提交时关联相关的 Issue 编号
|
|
1121
|
-
4. **破坏性变更** - 重要的 API 变更要标记 BREAKING CHANGE
|
|
1122
|
-
|
|
1123
|
-
## 🆚 与其他工具对比
|
|
1124
|
-
|
|
1125
|
-
| 特性 | git-workflow | git-flow | 手动操作 |
|
|
1126
|
-
| ---------------- | ------------- | ----------- | --------- |
|
|
1127
|
-
| 学习成本 | ⭐ 极低 | ⭐⭐⭐ 较高 | ⭐⭐ 中等 |
|
|
1128
|
-
| 分支命名规范 | ✅ 自动生成 | ❌ 需手动 | ❌ 需手动 |
|
|
1129
|
-
| 版本号管理 | ✅ 智能递增 | ❌ 需手动 | ❌ 需手动 |
|
|
1130
|
-
| Tag 管理 | ✅ 完整支持 | ⚠️ 基础 | ❌ 需手动 |
|
|
1131
|
-
| AI Commit | ✅ 支持 | ❌ 不支持 | ❌ 不支持 |
|
|
1132
|
-
| Stash 可视化管理 | ✅ 支持 | ❌ 不支持 | ❌ 不支持 |
|
|
1133
|
-
| 交互式操作 | ✅ 支持 | ❌ 不支持 | ❌ 不支持 |
|
|
1134
|
-
| 配置灵活性 | ✅ 项目级配置 | ⚠️ 有限 | - |
|
|
1135
|
-
| 远程分支同步 | ✅ 自动处理 | ⚠️ 部分 | ❌ 需手动 |
|
|
1136
|
-
| 自动更新提醒 | ✅ 支持 | ❌ 不支持 | - |
|
|
1137
|
-
|
|
1138
|
-
## 🛠️ 开发
|
|
208
|
+
### 快速开发
|
|
1139
209
|
|
|
1140
210
|
```bash
|
|
1141
211
|
# 克隆仓库
|
|
@@ -1148,92 +218,23 @@ npm install
|
|
|
1148
218
|
# 开发模式
|
|
1149
219
|
npm run dev
|
|
1150
220
|
|
|
1151
|
-
# 构建
|
|
1152
|
-
npm run build
|
|
1153
|
-
|
|
1154
221
|
# 运行测试
|
|
1155
222
|
npm test
|
|
1156
223
|
|
|
1157
|
-
#
|
|
1158
|
-
npm run test:watch
|
|
1159
|
-
|
|
1160
|
-
# 可视化测试界面
|
|
1161
|
-
npm run test:ui
|
|
1162
|
-
|
|
1163
|
-
# 生成测试覆盖率报告
|
|
1164
|
-
npm run test:coverage
|
|
1165
|
-
|
|
1166
|
-
# 本地测试
|
|
1167
|
-
npm link
|
|
1168
|
-
gw --version
|
|
1169
|
-
```
|
|
1170
|
-
|
|
1171
|
-
### 测试
|
|
1172
|
-
|
|
1173
|
-
本项目使用 [Vitest](https://vitest.dev/) 作为测试框架,确保每次变更不会影响现有功能。
|
|
1174
|
-
|
|
1175
|
-
**测试覆盖:**
|
|
1176
|
-
|
|
1177
|
-
- ✅ Tag 功能(前缀提取、分组、显示逻辑)
|
|
1178
|
-
- ✅ Commit 功能(提交类型、消息格式、emoji)
|
|
1179
|
-
- ✅ 工具函数
|
|
1180
|
-
|
|
1181
|
-
**运行测试:**
|
|
1182
|
-
|
|
1183
|
-
```bash
|
|
1184
|
-
# 单次运行所有测试
|
|
1185
|
-
npm test
|
|
1186
|
-
|
|
1187
|
-
# 监听模式(开发时推荐)
|
|
1188
|
-
npm run test:watch
|
|
1189
|
-
|
|
1190
|
-
# 可视化界面
|
|
1191
|
-
npm run test:ui
|
|
1192
|
-
|
|
1193
|
-
# 生成覆盖率报告
|
|
1194
|
-
npm run test:coverage
|
|
1195
|
-
```
|
|
1196
|
-
|
|
1197
|
-
**添加新测试:**
|
|
1198
|
-
|
|
1199
|
-
在 `tests/` 目录创建对应的测试文件:
|
|
1200
|
-
|
|
1201
|
-
```typescript
|
|
1202
|
-
import { describe, it, expect } from "vitest";
|
|
1203
|
-
|
|
1204
|
-
describe("新功能", () => {
|
|
1205
|
-
it("应该正确工作", () => {
|
|
1206
|
-
expect(result).toBe(expected);
|
|
1207
|
-
});
|
|
1208
|
-
});
|
|
1209
|
-
```
|
|
1210
|
-
|
|
1211
|
-
详细测试指南请查看 [tests/README.md](./tests/README.md)。
|
|
1212
|
-
|
|
1213
|
-
## 📦 发布
|
|
1214
|
-
|
|
1215
|
-
```bash
|
|
1216
|
-
# 使用内置发布脚本(推荐)
|
|
1217
|
-
npm run publish:npm
|
|
1218
|
-
|
|
1219
|
-
# 手动发布
|
|
224
|
+
# 构建
|
|
1220
225
|
npm run build
|
|
1221
|
-
npm run changelog
|
|
1222
|
-
npm version patch # 或 minor/major
|
|
1223
|
-
git push origin main --tags
|
|
1224
|
-
npm publish
|
|
1225
226
|
```
|
|
1226
227
|
|
|
1227
228
|
## 🤝 贡献
|
|
1228
229
|
|
|
1229
|
-
欢迎提交 Issue 和 Pull Request
|
|
1230
|
-
|
|
1231
|
-
在提交 PR 之前,请确保:
|
|
230
|
+
欢迎提交 Issue 和 Pull Request!在提交 PR 之前,请确保:
|
|
1232
231
|
|
|
1233
232
|
1. 代码通过 TypeScript 类型检查
|
|
1234
233
|
2. 遵循现有的代码风格
|
|
1235
|
-
3.
|
|
1236
|
-
4.
|
|
234
|
+
3. 添加必要的测试用例
|
|
235
|
+
4. 更新相关文档
|
|
236
|
+
|
|
237
|
+
详细贡献指南请查看:[贡献指南](https://iamzjt-front-end.github.io/git-workflow/guide/contributing)
|
|
1237
238
|
|
|
1238
239
|
## 📄 License
|
|
1239
240
|
|
|
@@ -1245,6 +246,10 @@ npm publish
|
|
|
1245
246
|
|
|
1246
247
|
---
|
|
1247
248
|
|
|
249
|
+
<p align="center">
|
|
250
|
+
<strong>📚 <a href="https://iamzjt-front-end.github.io/git-workflow/">完整文档</a> | 🚀 <a href="https://iamzjt-front-end.github.io/git-workflow/guide/getting-started">快速开始</a> | 📖 <a href="https://iamzjt-front-end.github.io/git-workflow/commands/">命令参考</a> | ⚙️ <a href="https://iamzjt-front-end.github.io/git-workflow/config/">配置指南</a></strong>
|
|
251
|
+
</p>
|
|
252
|
+
|
|
1248
253
|
<p align="center">
|
|
1249
254
|
<strong>如果这个工具对你有帮助,请给个 ⭐️ 支持一下!</strong>
|
|
1250
255
|
</p>
|
|
@@ -1252,5 +257,6 @@ npm publish
|
|
|
1252
257
|
<p align="center">
|
|
1253
258
|
<a href="https://github.com/iamzjt-front-end/git-workflow">GitHub</a> •
|
|
1254
259
|
<a href="https://www.npmjs.com/package/@zjex/git-workflow">npm</a> •
|
|
1255
|
-
<a href="https://github.com/iamzjt-front-end/git-workflow/issues">Issues</a>
|
|
260
|
+
<a href="https://github.com/iamzjt-front-end/git-workflow/issues">Issues</a> •
|
|
261
|
+
<a href="https://iamzjt-front-end.github.io/git-workflow/">文档</a>
|
|
1256
262
|
</p>
|