gitcode-cli 0.10.3__tar.gz → 0.11.0__tar.gz

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.
Files changed (22) hide show
  1. {gitcode_cli-0.10.3/gitcode_cli.egg-info → gitcode_cli-0.11.0}/PKG-INFO +61 -16
  2. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/README.md +60 -15
  3. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/__init__.py +1 -1
  4. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/bin/gc-darwin-amd64 +0 -0
  5. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/bin/gc-darwin-arm64 +0 -0
  6. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/bin/gc-linux-amd64 +0 -0
  7. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/bin/gc-linux-arm64 +0 -0
  8. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/bin/gc-windows-amd64.exe +0 -0
  9. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/wrapper.py +10 -2
  10. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0/gitcode_cli.egg-info}/PKG-INFO +61 -16
  11. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gitcode_cli.egg-info/SOURCES.txt +1 -0
  12. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/pyproject.toml +1 -1
  13. gitcode_cli-0.11.0/tests/test_verify_remote_facts.py +46 -0
  14. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/tests/test_wrapper.py +14 -0
  15. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/LICENSE +0 -0
  16. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/MANIFEST.in +0 -0
  17. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/__main__.py +0 -0
  18. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gc_cli/bin/.gitkeep +0 -0
  19. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gitcode_cli.egg-info/dependency_links.txt +0 -0
  20. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gitcode_cli.egg-info/entry_points.txt +0 -0
  21. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/gitcode_cli.egg-info/top_level.txt +0 -0
  22. {gitcode_cli-0.10.3 → gitcode_cli-0.11.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-cli
3
- Version: 0.10.3
3
+ Version: 0.11.0
4
4
  Summary: GitCode CLI - Command line tool for GitCode
5
5
  Author-email: GitCode CLI Contributors <support@gitcode.com>
6
6
  Maintainer-email: GitCode CLI Contributors <support@gitcode.com>
@@ -67,6 +67,17 @@ GitCode CLI 把仓库、Issue、PR、Release 和 Actions 带回终端,让开
67
67
 
68
68
  ## 安装
69
69
 
70
+ 推荐只让一个全局安装渠道拥有 `gc` / `gitcode`。Windows 普通用户和 Node/AI 环境优先使用 npm;macOS 优先 Homebrew;Debian/Ubuntu 优先 DEB;RHEL/Fedora 优先 RPM。Python wheel 建议放入 `pipx` 或虚拟环境,CI 建议固定版本并校验 checksum。
71
+
72
+ 安装或升级后可离线检查实际命令来源和全部 PATH 候选:
73
+
74
+ ```bash
75
+ gitcode doctor install
76
+ gitcode doctor install --json
77
+ ```
78
+
79
+ 诊断只读取公开的可执行文件、PATH 和本地安装 manifest,不读取认证配置或 Token,也不会卸载其他渠道或修改 PATH。
80
+
70
81
  ### 从源码构建
71
82
 
72
83
  **前置要求:**
@@ -83,11 +94,8 @@ go build -o gc ./cmd/gc
83
94
  mkdir -p ~/.local/bin
84
95
  mv gc ~/.local/bin/
85
96
 
86
- # 方式二:使用 make build(带完整版本标签)
87
- make build
88
- # 安装
89
- mkdir -p ~/.local/bin
90
- mv bin/gc ~/.local/bin/
97
+ # 方式二:构建并安装 gc/gitcode(带完整版本标签)
98
+ make install PREFIX="$HOME/.local"
91
99
 
92
100
  # 添加到 PATH
93
101
  export PATH="$HOME/.local/bin:$PATH"
@@ -103,10 +111,10 @@ export PATH="$HOME/.local/bin:$PATH"
103
111
 
104
112
  ```bash
105
113
  # 从 Releases 下载 .deb 包
106
- wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gc_0.10.3_amd64.deb
114
+ wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gc_0.11.0_amd64.deb
107
115
 
108
116
  # 安装
109
- sudo dpkg -i gc_0.10.3_amd64.deb
117
+ sudo dpkg -i gc_0.11.0_amd64.deb
110
118
  ```
111
119
 
112
120
  DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
@@ -115,15 +123,15 @@ DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
115
123
 
116
124
  ```bash
117
125
  # 从 Releases 下载 .rpm 包
118
- wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gc-0.10.3-1.x86_64.rpm
126
+ wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gc-0.11.0-1.x86_64.rpm
119
127
 
120
128
  # 安装
121
- sudo rpm -i gc-0.10.3-1.x86_64.rpm
129
+ sudo rpm -i gc-0.11.0-1.x86_64.rpm
122
130
  ```
123
131
 
124
132
  DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
125
133
 
126
- ### Wheel 包(跨平台,推荐)
134
+ ### Wheel 包(跨平台、隔离安装)
127
135
 
128
136
  从 Release 归档下载 wheel 包安装,**内置全平台二进制**(Linux x64/ARM、macOS Intel/Apple Silicon、Windows x64):
129
137
 
@@ -134,7 +142,7 @@ source .venv/bin/activate # Linux/macOS
134
142
  # .\.venv\Scripts\Activate.ps1 # Windows PowerShell
135
143
 
136
144
  # 安装(一行命令)
137
- pip install https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gitcode_cli-0.10.3-py3-none-any.whl
145
+ pip install https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gitcode_cli-0.11.0-py3-none-any.whl
138
146
 
139
147
  # Windows PowerShell 中推荐使用 gitcode,避免 gc 被内置 Get-Content 别名覆盖
140
148
  gitcode version
@@ -143,6 +151,7 @@ gitcode version
143
151
  说明:
144
152
  - wheel 会同时安装 `gc` 和 `gitcode` 两个命令入口,功能相同。
145
153
  - DEB/RPM 包也会同时安装 `gc` 和 `gitcode`;Linux 上二者功能相同。
154
+ - 不建议让 pip user install 与 DEB/RPM/Homebrew/npm 同时提供全局命令。已混用时先运行 `gitcode doctor install` 确认实际选中路径,再由用户明确选择调整 PATH、升级原渠道或卸载旧渠道;CLI 不会代替用户调用其他包管理器。
146
155
  - Windows 使用 `py -m pip install --user ...` 时,脚本会安装到 Python user scheme 的 `Scripts` 目录。请运行 `py -c "import os, sysconfig; print(sysconfig.get_path('scripts', os.name + '_user'))"` 获取准确路径,将其加入用户 `PATH` 后重新打开终端;配置前可直接运行 `py -m gc_cli version`。
147
156
  - Windows PowerShell 预置 `gc` 作为 `Get-Content` 别名;如果 `gc version` 被解析为读取文件,请改用 `gitcode version`、`gc.exe version` 或 `py -m gc_cli version`。
148
157
  - Windows PowerShell 中通过 `--body-file -` / `--comment-file -` 管道传入中文或其他非 ASCII 正文时,推荐使用 UTF-8 文件;如果必须直接管道,先设置 `$OutputEncoding = [System.Text.UTF8Encoding]::new($false)`。CLI 会拦截疑似已被 PowerShell 损坏成 `???` 的输入并提示正确用法。
@@ -163,7 +172,7 @@ source .venv/bin/activate # Linux/macOS
163
172
  # .\.venv\Scripts\Activate.ps1 # Windows PowerShell
164
173
 
165
174
  # 固定版本安装,避免 PyPI 尚未同步时安装旧版本
166
- python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.10.3
175
+ python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.11.0
167
176
 
168
177
  # Windows PowerShell 中推荐使用 gitcode
169
178
  gitcode version
@@ -185,13 +194,16 @@ gitcode version
185
194
  ```bash
186
195
  chmod +x gc_linux_amd64
187
196
  mv gc_linux_amd64 ~/.local/bin/gc
197
+ ln -s gc ~/.local/bin/gitcode
188
198
  gc version
189
199
  ```
190
200
 
191
- Windows 和 macOS 用户建议使用上方 wheel 包;wheel 内置 Linux、macOS 和 Windows 二进制,并同时提供 `gc` 与 `gitcode` 两个命令入口。
201
+ 需要与系统包管理器隔离时可使用上方 wheel;需要免安装直接部署时使用独立二进制。二者都应先确认平台架构受支持。
192
202
 
193
203
  ### Docker 镜像
194
204
 
205
+ > **用途说明**:本仓库 Docker 配置面向开发/构建环境。`docker compose up gc` 默认执行 `gc --help` 展示用法后退出(CLI 工具非长期服务)。交互式使用 `docker run -it --entrypoint bash gitcode/gc:dev`(进入 shell)或 `docker run -it gitcode/gc:dev <子命令>`(如 `auth login`)。
206
+
195
207
  仓库已提供 `Dockerfile`、`docker-compose.yml` 和 Makefile 目标:
196
208
 
197
209
  ```bash
@@ -227,6 +239,7 @@ brew upgrade gc
227
239
  ```
228
240
 
229
241
  shell 补全(bash/zsh/fish)随安装自动配置,无需额外操作。
242
+ Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm 旧入口遮蔽。
230
243
 
231
244
  ### npm (跨平台)
232
245
 
@@ -240,10 +253,39 @@ npx @gitcode-cli/cli@latest install
240
253
 
241
254
  ```bash
242
255
  npm install -g @gitcode-cli/cli
243
- gc version
256
+ gitcode version
244
257
  ```
245
258
 
246
- 包内置 Linux/macOS/Windows 多平台二进制;shell 补全(bash/zsh/fish)由 `install` 子命令自动配置。
259
+ 如果 `gitcode version` 仍显示旧的 pip/wheel 版本,先直接调用 npm 安装目录中的新入口诊断,不必先卸载 pip:
260
+
261
+ ```powershell
262
+ # Windows PowerShell
263
+ & "$(npm prefix -g)\gitcode.cmd" doctor install --json
264
+ ```
265
+
266
+ ```bash
267
+ # Linux/macOS
268
+ "$(npm prefix -g)/bin/gitcode" doctor install --json
269
+ ```
270
+
271
+ 包内置 Linux/macOS/Windows 多平台二进制。Windows bootstrap 同时安装 `gc.exe` 和 `gitcode.exe`,PowerShell 请使用 `gitcode`,避免内置 `gc`/`Get-Content` alias。
272
+
273
+ npm global 与 npm bootstrap 默认使用 `notify` 模式:命令本身立即执行,24 小时 TTL 到期后在后台检查 stable `latest`,发现新版后在下一次启动提示 `gitcode update`,不会自动安装,也不会改变刚完成命令的退出码。需要自动应用的用户可明确启用 `auto`;该模式具有跨进程锁、版本健康检查和失败回滚。
274
+
275
+ ```bash
276
+ gitcode update --check # 只检查
277
+ gitcode update # 显式更新当前 npm 渠道
278
+ gitcode update --json
279
+
280
+ gitcode config set update.mode auto
281
+ gitcode config set update.mode notify
282
+ gitcode config set update.mode off
283
+
284
+ gitcode --no-update-check version # 单次禁用
285
+ GC_NO_UPDATE_CHECK=1 gitcode version
286
+ ```
287
+
288
+ `CI=true`、`--no-interactive`、`--no-update-check` 或 `GC_NO_UPDATE_CHECK=1` 会禁用后台检查。更新器仅从官方 `https://registry.npmjs.org` 获取精确 stable 版本,安装时禁用生命周期脚本,并以最小环境启动;它不会调用 pip、Homebrew、apt、dnf,也不会静默修改 PATH。npm 生命周期脚本被组织策略禁用时,可直接运行 npm prefix 中的 `gitcode` 再执行 `doctor install`;wrapper 会在首次直接运行时补建来源 metadata。
247
289
 
248
290
  ### 规划中的安装方式
249
291
 
@@ -381,6 +423,9 @@ gitcode actions artifact download <artifact-id> -R owner/repo --output artifact.
381
423
  # 删除 artifact
382
424
  gitcode actions artifact delete <artifact-id> -R owner/repo --yes
383
425
 
426
+ # 校验 workflow YAML
427
+ gitcode actions yaml validate --file .gitcode/workflows/ci.yml -R owner/repo
428
+
384
429
  # 调用 GitCode API 原始响应
385
430
  gitcode api repos/owner/repo
386
431
 
@@ -38,6 +38,17 @@ GitCode CLI 把仓库、Issue、PR、Release 和 Actions 带回终端,让开
38
38
 
39
39
  ## 安装
40
40
 
41
+ 推荐只让一个全局安装渠道拥有 `gc` / `gitcode`。Windows 普通用户和 Node/AI 环境优先使用 npm;macOS 优先 Homebrew;Debian/Ubuntu 优先 DEB;RHEL/Fedora 优先 RPM。Python wheel 建议放入 `pipx` 或虚拟环境,CI 建议固定版本并校验 checksum。
42
+
43
+ 安装或升级后可离线检查实际命令来源和全部 PATH 候选:
44
+
45
+ ```bash
46
+ gitcode doctor install
47
+ gitcode doctor install --json
48
+ ```
49
+
50
+ 诊断只读取公开的可执行文件、PATH 和本地安装 manifest,不读取认证配置或 Token,也不会卸载其他渠道或修改 PATH。
51
+
41
52
  ### 从源码构建
42
53
 
43
54
  **前置要求:**
@@ -54,11 +65,8 @@ go build -o gc ./cmd/gc
54
65
  mkdir -p ~/.local/bin
55
66
  mv gc ~/.local/bin/
56
67
 
57
- # 方式二:使用 make build(带完整版本标签)
58
- make build
59
- # 安装
60
- mkdir -p ~/.local/bin
61
- mv bin/gc ~/.local/bin/
68
+ # 方式二:构建并安装 gc/gitcode(带完整版本标签)
69
+ make install PREFIX="$HOME/.local"
62
70
 
63
71
  # 添加到 PATH
64
72
  export PATH="$HOME/.local/bin:$PATH"
@@ -74,10 +82,10 @@ export PATH="$HOME/.local/bin:$PATH"
74
82
 
75
83
  ```bash
76
84
  # 从 Releases 下载 .deb 包
77
- wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gc_0.10.3_amd64.deb
85
+ wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gc_0.11.0_amd64.deb
78
86
 
79
87
  # 安装
80
- sudo dpkg -i gc_0.10.3_amd64.deb
88
+ sudo dpkg -i gc_0.11.0_amd64.deb
81
89
  ```
82
90
 
83
91
  DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
@@ -86,15 +94,15 @@ DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
86
94
 
87
95
  ```bash
88
96
  # 从 Releases 下载 .rpm 包
89
- wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gc-0.10.3-1.x86_64.rpm
97
+ wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gc-0.11.0-1.x86_64.rpm
90
98
 
91
99
  # 安装
92
- sudo rpm -i gc-0.10.3-1.x86_64.rpm
100
+ sudo rpm -i gc-0.11.0-1.x86_64.rpm
93
101
  ```
94
102
 
95
103
  DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
96
104
 
97
- ### Wheel 包(跨平台,推荐)
105
+ ### Wheel 包(跨平台、隔离安装)
98
106
 
99
107
  从 Release 归档下载 wheel 包安装,**内置全平台二进制**(Linux x64/ARM、macOS Intel/Apple Silicon、Windows x64):
100
108
 
@@ -105,7 +113,7 @@ source .venv/bin/activate # Linux/macOS
105
113
  # .\.venv\Scripts\Activate.ps1 # Windows PowerShell
106
114
 
107
115
  # 安装(一行命令)
108
- pip install https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gitcode_cli-0.10.3-py3-none-any.whl
116
+ pip install https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gitcode_cli-0.11.0-py3-none-any.whl
109
117
 
110
118
  # Windows PowerShell 中推荐使用 gitcode,避免 gc 被内置 Get-Content 别名覆盖
111
119
  gitcode version
@@ -114,6 +122,7 @@ gitcode version
114
122
  说明:
115
123
  - wheel 会同时安装 `gc` 和 `gitcode` 两个命令入口,功能相同。
116
124
  - DEB/RPM 包也会同时安装 `gc` 和 `gitcode`;Linux 上二者功能相同。
125
+ - 不建议让 pip user install 与 DEB/RPM/Homebrew/npm 同时提供全局命令。已混用时先运行 `gitcode doctor install` 确认实际选中路径,再由用户明确选择调整 PATH、升级原渠道或卸载旧渠道;CLI 不会代替用户调用其他包管理器。
117
126
  - Windows 使用 `py -m pip install --user ...` 时,脚本会安装到 Python user scheme 的 `Scripts` 目录。请运行 `py -c "import os, sysconfig; print(sysconfig.get_path('scripts', os.name + '_user'))"` 获取准确路径,将其加入用户 `PATH` 后重新打开终端;配置前可直接运行 `py -m gc_cli version`。
118
127
  - Windows PowerShell 预置 `gc` 作为 `Get-Content` 别名;如果 `gc version` 被解析为读取文件,请改用 `gitcode version`、`gc.exe version` 或 `py -m gc_cli version`。
119
128
  - Windows PowerShell 中通过 `--body-file -` / `--comment-file -` 管道传入中文或其他非 ASCII 正文时,推荐使用 UTF-8 文件;如果必须直接管道,先设置 `$OutputEncoding = [System.Text.UTF8Encoding]::new($false)`。CLI 会拦截疑似已被 PowerShell 损坏成 `???` 的输入并提示正确用法。
@@ -134,7 +143,7 @@ source .venv/bin/activate # Linux/macOS
134
143
  # .\.venv\Scripts\Activate.ps1 # Windows PowerShell
135
144
 
136
145
  # 固定版本安装,避免 PyPI 尚未同步时安装旧版本
137
- python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.10.3
146
+ python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.11.0
138
147
 
139
148
  # Windows PowerShell 中推荐使用 gitcode
140
149
  gitcode version
@@ -156,13 +165,16 @@ gitcode version
156
165
  ```bash
157
166
  chmod +x gc_linux_amd64
158
167
  mv gc_linux_amd64 ~/.local/bin/gc
168
+ ln -s gc ~/.local/bin/gitcode
159
169
  gc version
160
170
  ```
161
171
 
162
- Windows 和 macOS 用户建议使用上方 wheel 包;wheel 内置 Linux、macOS 和 Windows 二进制,并同时提供 `gc` 与 `gitcode` 两个命令入口。
172
+ 需要与系统包管理器隔离时可使用上方 wheel;需要免安装直接部署时使用独立二进制。二者都应先确认平台架构受支持。
163
173
 
164
174
  ### Docker 镜像
165
175
 
176
+ > **用途说明**:本仓库 Docker 配置面向开发/构建环境。`docker compose up gc` 默认执行 `gc --help` 展示用法后退出(CLI 工具非长期服务)。交互式使用 `docker run -it --entrypoint bash gitcode/gc:dev`(进入 shell)或 `docker run -it gitcode/gc:dev <子命令>`(如 `auth login`)。
177
+
166
178
  仓库已提供 `Dockerfile`、`docker-compose.yml` 和 Makefile 目标:
167
179
 
168
180
  ```bash
@@ -198,6 +210,7 @@ brew upgrade gc
198
210
  ```
199
211
 
200
212
  shell 补全(bash/zsh/fish)随安装自动配置,无需额外操作。
213
+ Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm 旧入口遮蔽。
201
214
 
202
215
  ### npm (跨平台)
203
216
 
@@ -211,10 +224,39 @@ npx @gitcode-cli/cli@latest install
211
224
 
212
225
  ```bash
213
226
  npm install -g @gitcode-cli/cli
214
- gc version
227
+ gitcode version
215
228
  ```
216
229
 
217
- 包内置 Linux/macOS/Windows 多平台二进制;shell 补全(bash/zsh/fish)由 `install` 子命令自动配置。
230
+ 如果 `gitcode version` 仍显示旧的 pip/wheel 版本,先直接调用 npm 安装目录中的新入口诊断,不必先卸载 pip:
231
+
232
+ ```powershell
233
+ # Windows PowerShell
234
+ & "$(npm prefix -g)\gitcode.cmd" doctor install --json
235
+ ```
236
+
237
+ ```bash
238
+ # Linux/macOS
239
+ "$(npm prefix -g)/bin/gitcode" doctor install --json
240
+ ```
241
+
242
+ 包内置 Linux/macOS/Windows 多平台二进制。Windows bootstrap 同时安装 `gc.exe` 和 `gitcode.exe`,PowerShell 请使用 `gitcode`,避免内置 `gc`/`Get-Content` alias。
243
+
244
+ npm global 与 npm bootstrap 默认使用 `notify` 模式:命令本身立即执行,24 小时 TTL 到期后在后台检查 stable `latest`,发现新版后在下一次启动提示 `gitcode update`,不会自动安装,也不会改变刚完成命令的退出码。需要自动应用的用户可明确启用 `auto`;该模式具有跨进程锁、版本健康检查和失败回滚。
245
+
246
+ ```bash
247
+ gitcode update --check # 只检查
248
+ gitcode update # 显式更新当前 npm 渠道
249
+ gitcode update --json
250
+
251
+ gitcode config set update.mode auto
252
+ gitcode config set update.mode notify
253
+ gitcode config set update.mode off
254
+
255
+ gitcode --no-update-check version # 单次禁用
256
+ GC_NO_UPDATE_CHECK=1 gitcode version
257
+ ```
258
+
259
+ `CI=true`、`--no-interactive`、`--no-update-check` 或 `GC_NO_UPDATE_CHECK=1` 会禁用后台检查。更新器仅从官方 `https://registry.npmjs.org` 获取精确 stable 版本,安装时禁用生命周期脚本,并以最小环境启动;它不会调用 pip、Homebrew、apt、dnf,也不会静默修改 PATH。npm 生命周期脚本被组织策略禁用时,可直接运行 npm prefix 中的 `gitcode` 再执行 `doctor install`;wrapper 会在首次直接运行时补建来源 metadata。
218
260
 
219
261
  ### 规划中的安装方式
220
262
 
@@ -352,6 +394,9 @@ gitcode actions artifact download <artifact-id> -R owner/repo --output artifact.
352
394
  # 删除 artifact
353
395
  gitcode actions artifact delete <artifact-id> -R owner/repo --yes
354
396
 
397
+ # 校验 workflow YAML
398
+ gitcode actions yaml validate --file .gitcode/workflows/ci.yml -R owner/repo
399
+
355
400
  # 调用 GitCode API 原始响应
356
401
  gitcode api repos/owner/repo
357
402
 
@@ -4,7 +4,7 @@ GitCode CLI - Command line tool for GitCode.
4
4
  This package provides a Python wrapper for the gc binary.
5
5
  """
6
6
 
7
- __version__ = "0.10.3"
7
+ __version__ = "0.11.0"
8
8
  __author__ = "GitCode CLI Contributors"
9
9
  __all__ = ["__version__", "main"]
10
10
 
@@ -12,6 +12,9 @@ import sys
12
12
  from pathlib import Path
13
13
 
14
14
  COMMAND_NAME_ENV = "GITCODE_CLI_COMMAND_NAME"
15
+ DISTRIBUTION_ENV = "GITCODE_CLI_DISTRIBUTION"
16
+ ENTRYPOINT_ENV = "GITCODE_CLI_ENTRYPOINT"
17
+ BINARY_ENV = "GITCODE_CLI_BINARY"
15
18
 
16
19
 
17
20
  def get_binary_name() -> str:
@@ -26,14 +29,16 @@ def get_binary_name() -> str:
26
29
  "aarch64": "arm64",
27
30
  "arm64": "arm64",
28
31
  }
29
- arch = arch_map.get(machine, "amd64")
32
+ arch = arch_map.get(machine)
33
+ if arch is None:
34
+ raise RuntimeError(f"Unsupported platform: {system} {machine}")
30
35
 
31
36
  # Map system to binary name
32
37
  if system == "linux":
33
38
  return f"gc-linux-{arch}"
34
39
  elif system == "darwin":
35
40
  return f"gc-darwin-{arch}"
36
- elif system == "windows":
41
+ elif system == "windows" and arch == "amd64":
37
42
  return "gc-windows-amd64.exe"
38
43
  else:
39
44
  raise RuntimeError(f"Unsupported platform: {system} {machine}")
@@ -80,6 +85,9 @@ def main() -> int:
80
85
  ensure_executable(binary_path)
81
86
  env = os.environ.copy()
82
87
  env.setdefault(COMMAND_NAME_ENV, get_command_name())
88
+ env.setdefault(DISTRIBUTION_ENV, "pypi")
89
+ env.setdefault(ENTRYPOINT_ENV, str(Path(sys.argv[0]).resolve()))
90
+ env.setdefault(BINARY_ENV, str(binary_path.resolve()))
83
91
 
84
92
  # Run the binary with all arguments
85
93
  result = subprocess.run(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-cli
3
- Version: 0.10.3
3
+ Version: 0.11.0
4
4
  Summary: GitCode CLI - Command line tool for GitCode
5
5
  Author-email: GitCode CLI Contributors <support@gitcode.com>
6
6
  Maintainer-email: GitCode CLI Contributors <support@gitcode.com>
@@ -67,6 +67,17 @@ GitCode CLI 把仓库、Issue、PR、Release 和 Actions 带回终端,让开
67
67
 
68
68
  ## 安装
69
69
 
70
+ 推荐只让一个全局安装渠道拥有 `gc` / `gitcode`。Windows 普通用户和 Node/AI 环境优先使用 npm;macOS 优先 Homebrew;Debian/Ubuntu 优先 DEB;RHEL/Fedora 优先 RPM。Python wheel 建议放入 `pipx` 或虚拟环境,CI 建议固定版本并校验 checksum。
71
+
72
+ 安装或升级后可离线检查实际命令来源和全部 PATH 候选:
73
+
74
+ ```bash
75
+ gitcode doctor install
76
+ gitcode doctor install --json
77
+ ```
78
+
79
+ 诊断只读取公开的可执行文件、PATH 和本地安装 manifest,不读取认证配置或 Token,也不会卸载其他渠道或修改 PATH。
80
+
70
81
  ### 从源码构建
71
82
 
72
83
  **前置要求:**
@@ -83,11 +94,8 @@ go build -o gc ./cmd/gc
83
94
  mkdir -p ~/.local/bin
84
95
  mv gc ~/.local/bin/
85
96
 
86
- # 方式二:使用 make build(带完整版本标签)
87
- make build
88
- # 安装
89
- mkdir -p ~/.local/bin
90
- mv bin/gc ~/.local/bin/
97
+ # 方式二:构建并安装 gc/gitcode(带完整版本标签)
98
+ make install PREFIX="$HOME/.local"
91
99
 
92
100
  # 添加到 PATH
93
101
  export PATH="$HOME/.local/bin:$PATH"
@@ -103,10 +111,10 @@ export PATH="$HOME/.local/bin:$PATH"
103
111
 
104
112
  ```bash
105
113
  # 从 Releases 下载 .deb 包
106
- wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gc_0.10.3_amd64.deb
114
+ wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gc_0.11.0_amd64.deb
107
115
 
108
116
  # 安装
109
- sudo dpkg -i gc_0.10.3_amd64.deb
117
+ sudo dpkg -i gc_0.11.0_amd64.deb
110
118
  ```
111
119
 
112
120
  DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
@@ -115,15 +123,15 @@ DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
115
123
 
116
124
  ```bash
117
125
  # 从 Releases 下载 .rpm 包
118
- wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gc-0.10.3-1.x86_64.rpm
126
+ wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gc-0.11.0-1.x86_64.rpm
119
127
 
120
128
  # 安装
121
- sudo rpm -i gc-0.10.3-1.x86_64.rpm
129
+ sudo rpm -i gc-0.11.0-1.x86_64.rpm
122
130
  ```
123
131
 
124
132
  DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
125
133
 
126
- ### Wheel 包(跨平台,推荐)
134
+ ### Wheel 包(跨平台、隔离安装)
127
135
 
128
136
  从 Release 归档下载 wheel 包安装,**内置全平台二进制**(Linux x64/ARM、macOS Intel/Apple Silicon、Windows x64):
129
137
 
@@ -134,7 +142,7 @@ source .venv/bin/activate # Linux/macOS
134
142
  # .\.venv\Scripts\Activate.ps1 # Windows PowerShell
135
143
 
136
144
  # 安装(一行命令)
137
- pip install https://gitcode.com/gitcode-cli/cli/releases/download/v0.10.3/gitcode_cli-0.10.3-py3-none-any.whl
145
+ pip install https://gitcode.com/gitcode-cli/cli/releases/download/v0.11.0/gitcode_cli-0.11.0-py3-none-any.whl
138
146
 
139
147
  # Windows PowerShell 中推荐使用 gitcode,避免 gc 被内置 Get-Content 别名覆盖
140
148
  gitcode version
@@ -143,6 +151,7 @@ gitcode version
143
151
  说明:
144
152
  - wheel 会同时安装 `gc` 和 `gitcode` 两个命令入口,功能相同。
145
153
  - DEB/RPM 包也会同时安装 `gc` 和 `gitcode`;Linux 上二者功能相同。
154
+ - 不建议让 pip user install 与 DEB/RPM/Homebrew/npm 同时提供全局命令。已混用时先运行 `gitcode doctor install` 确认实际选中路径,再由用户明确选择调整 PATH、升级原渠道或卸载旧渠道;CLI 不会代替用户调用其他包管理器。
146
155
  - Windows 使用 `py -m pip install --user ...` 时,脚本会安装到 Python user scheme 的 `Scripts` 目录。请运行 `py -c "import os, sysconfig; print(sysconfig.get_path('scripts', os.name + '_user'))"` 获取准确路径,将其加入用户 `PATH` 后重新打开终端;配置前可直接运行 `py -m gc_cli version`。
147
156
  - Windows PowerShell 预置 `gc` 作为 `Get-Content` 别名;如果 `gc version` 被解析为读取文件,请改用 `gitcode version`、`gc.exe version` 或 `py -m gc_cli version`。
148
157
  - Windows PowerShell 中通过 `--body-file -` / `--comment-file -` 管道传入中文或其他非 ASCII 正文时,推荐使用 UTF-8 文件;如果必须直接管道,先设置 `$OutputEncoding = [System.Text.UTF8Encoding]::new($false)`。CLI 会拦截疑似已被 PowerShell 损坏成 `???` 的输入并提示正确用法。
@@ -163,7 +172,7 @@ source .venv/bin/activate # Linux/macOS
163
172
  # .\.venv\Scripts\Activate.ps1 # Windows PowerShell
164
173
 
165
174
  # 固定版本安装,避免 PyPI 尚未同步时安装旧版本
166
- python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.10.3
175
+ python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.11.0
167
176
 
168
177
  # Windows PowerShell 中推荐使用 gitcode
169
178
  gitcode version
@@ -185,13 +194,16 @@ gitcode version
185
194
  ```bash
186
195
  chmod +x gc_linux_amd64
187
196
  mv gc_linux_amd64 ~/.local/bin/gc
197
+ ln -s gc ~/.local/bin/gitcode
188
198
  gc version
189
199
  ```
190
200
 
191
- Windows 和 macOS 用户建议使用上方 wheel 包;wheel 内置 Linux、macOS 和 Windows 二进制,并同时提供 `gc` 与 `gitcode` 两个命令入口。
201
+ 需要与系统包管理器隔离时可使用上方 wheel;需要免安装直接部署时使用独立二进制。二者都应先确认平台架构受支持。
192
202
 
193
203
  ### Docker 镜像
194
204
 
205
+ > **用途说明**:本仓库 Docker 配置面向开发/构建环境。`docker compose up gc` 默认执行 `gc --help` 展示用法后退出(CLI 工具非长期服务)。交互式使用 `docker run -it --entrypoint bash gitcode/gc:dev`(进入 shell)或 `docker run -it gitcode/gc:dev <子命令>`(如 `auth login`)。
206
+
195
207
  仓库已提供 `Dockerfile`、`docker-compose.yml` 和 Makefile 目标:
196
208
 
197
209
  ```bash
@@ -227,6 +239,7 @@ brew upgrade gc
227
239
  ```
228
240
 
229
241
  shell 补全(bash/zsh/fish)随安装自动配置,无需额外操作。
242
+ Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm 旧入口遮蔽。
230
243
 
231
244
  ### npm (跨平台)
232
245
 
@@ -240,10 +253,39 @@ npx @gitcode-cli/cli@latest install
240
253
 
241
254
  ```bash
242
255
  npm install -g @gitcode-cli/cli
243
- gc version
256
+ gitcode version
244
257
  ```
245
258
 
246
- 包内置 Linux/macOS/Windows 多平台二进制;shell 补全(bash/zsh/fish)由 `install` 子命令自动配置。
259
+ 如果 `gitcode version` 仍显示旧的 pip/wheel 版本,先直接调用 npm 安装目录中的新入口诊断,不必先卸载 pip:
260
+
261
+ ```powershell
262
+ # Windows PowerShell
263
+ & "$(npm prefix -g)\gitcode.cmd" doctor install --json
264
+ ```
265
+
266
+ ```bash
267
+ # Linux/macOS
268
+ "$(npm prefix -g)/bin/gitcode" doctor install --json
269
+ ```
270
+
271
+ 包内置 Linux/macOS/Windows 多平台二进制。Windows bootstrap 同时安装 `gc.exe` 和 `gitcode.exe`,PowerShell 请使用 `gitcode`,避免内置 `gc`/`Get-Content` alias。
272
+
273
+ npm global 与 npm bootstrap 默认使用 `notify` 模式:命令本身立即执行,24 小时 TTL 到期后在后台检查 stable `latest`,发现新版后在下一次启动提示 `gitcode update`,不会自动安装,也不会改变刚完成命令的退出码。需要自动应用的用户可明确启用 `auto`;该模式具有跨进程锁、版本健康检查和失败回滚。
274
+
275
+ ```bash
276
+ gitcode update --check # 只检查
277
+ gitcode update # 显式更新当前 npm 渠道
278
+ gitcode update --json
279
+
280
+ gitcode config set update.mode auto
281
+ gitcode config set update.mode notify
282
+ gitcode config set update.mode off
283
+
284
+ gitcode --no-update-check version # 单次禁用
285
+ GC_NO_UPDATE_CHECK=1 gitcode version
286
+ ```
287
+
288
+ `CI=true`、`--no-interactive`、`--no-update-check` 或 `GC_NO_UPDATE_CHECK=1` 会禁用后台检查。更新器仅从官方 `https://registry.npmjs.org` 获取精确 stable 版本,安装时禁用生命周期脚本,并以最小环境启动;它不会调用 pip、Homebrew、apt、dnf,也不会静默修改 PATH。npm 生命周期脚本被组织策略禁用时,可直接运行 npm prefix 中的 `gitcode` 再执行 `doctor install`;wrapper 会在首次直接运行时补建来源 metadata。
247
289
 
248
290
  ### 规划中的安装方式
249
291
 
@@ -381,6 +423,9 @@ gitcode actions artifact download <artifact-id> -R owner/repo --output artifact.
381
423
  # 删除 artifact
382
424
  gitcode actions artifact delete <artifact-id> -R owner/repo --yes
383
425
 
426
+ # 校验 workflow YAML
427
+ gitcode actions yaml validate --file .gitcode/workflows/ci.yml -R owner/repo
428
+
384
429
  # 调用 GitCode API 原始响应
385
430
  gitcode api repos/owner/repo
386
431
 
@@ -16,4 +16,5 @@ gitcode_cli.egg-info/SOURCES.txt
16
16
  gitcode_cli.egg-info/dependency_links.txt
17
17
  gitcode_cli.egg-info/entry_points.txt
18
18
  gitcode_cli.egg-info/top_level.txt
19
+ tests/test_verify_remote_facts.py
19
20
  tests/test_wrapper.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gitcode-cli"
7
- version = "0.10.3"
7
+ version = "0.11.0"
8
8
  description = "GitCode CLI - Command line tool for GitCode"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -0,0 +1,46 @@
1
+ import importlib.util
2
+ import json
3
+ import sys
4
+ import unittest
5
+ from pathlib import Path
6
+ from unittest import mock
7
+
8
+ # verify-remote-facts.py has a hyphen in its name so it cannot be imported
9
+ # normally; load it via importlib and register it so mock.patch can find it.
10
+ _spec = importlib.util.spec_from_file_location(
11
+ "verify_remote_facts",
12
+ Path(__file__).parent.parent / "scripts" / "verify-remote-facts.py",
13
+ )
14
+ vrf = importlib.util.module_from_spec(_spec)
15
+ sys.modules["verify_remote_facts"] = vrf
16
+ _spec.loader.exec_module(vrf)
17
+
18
+
19
+ class VerifyRemoteFactsEncodingTests(unittest.TestCase):
20
+ def test_run_json_decodes_utf8_chinese(self):
21
+ """run_json must decode UTF-8 Chinese JSON output (Windows GBK fix #479)."""
22
+ chinese_json = json.dumps({"title": "修复中文测试", "state": "closed"})
23
+ mock_result = mock.Mock(returncode=0, stdout=chinese_json, stderr="")
24
+ with mock.patch("verify_remote_facts.subprocess.run", return_value=mock_result) as run:
25
+ data = vrf.run_json(["./gc", "issue", "view", "1", "--json"])
26
+ self.assertEqual(data["title"], "修复中文测试")
27
+ _, kwargs = run.call_args
28
+ self.assertEqual(kwargs.get("encoding"), "utf-8")
29
+
30
+ def test_run_json_raises_on_nonzero_exit(self):
31
+ mock_result = mock.Mock(returncode=1, stdout="", stderr="boom")
32
+ with mock.patch("verify_remote_facts.subprocess.run", return_value=mock_result):
33
+ with self.assertRaises(SystemExit):
34
+ vrf.run_json(["./gc", "issue", "view", "1", "--json"])
35
+
36
+ def test_merged_in_main_uses_utf8_encoding(self):
37
+ """merged_in_main must pass encoding=utf-8 (#479)."""
38
+ mock_result = mock.Mock(returncode=0, stdout="", stderr="")
39
+ with mock.patch("verify_remote_facts.subprocess.run", return_value=mock_result) as run:
40
+ self.assertTrue(vrf.merged_in_main("abc123"))
41
+ _, kwargs = run.call_args
42
+ self.assertEqual(kwargs.get("encoding"), "utf-8")
43
+
44
+
45
+ if __name__ == "__main__":
46
+ unittest.main()
@@ -15,6 +15,18 @@ class WrapperTests(unittest.TestCase):
15
15
  with mock.patch("platform.machine", return_value="AMD64"):
16
16
  self.assertEqual(wrapper.get_binary_name(), "gc-windows-amd64.exe")
17
17
 
18
+ def test_unknown_architecture_is_rejected(self):
19
+ with mock.patch("platform.system", return_value="Linux"):
20
+ with mock.patch("platform.machine", return_value="riscv64"):
21
+ with self.assertRaisesRegex(RuntimeError, "Unsupported platform: linux riscv64"):
22
+ wrapper.get_binary_name()
23
+
24
+ def test_windows_arm64_is_rejected_until_a_binary_is_shipped(self):
25
+ with mock.patch("platform.system", return_value="Windows"):
26
+ with mock.patch("platform.machine", return_value="ARM64"):
27
+ with self.assertRaisesRegex(RuntimeError, "Unsupported platform: windows arm64"):
28
+ wrapper.get_binary_name()
29
+
18
30
  def test_ensure_executable_skips_windows_execute_bit_check(self):
19
31
  with tempfile.NamedTemporaryFile() as tmp:
20
32
  path = Path(tmp.name)
@@ -48,6 +60,8 @@ class WrapperTests(unittest.TestCase):
48
60
  self.assertEqual(args[0], [str(binary), "version"])
49
61
  self.assertEqual(kwargs["cwd"], os.getcwd())
50
62
  self.assertEqual(kwargs["env"][wrapper.COMMAND_NAME_ENV], "gitcode")
63
+ self.assertEqual(kwargs["env"][wrapper.DISTRIBUTION_ENV], "pypi")
64
+ self.assertEqual(kwargs["env"][wrapper.BINARY_ENV], str(binary.resolve()))
51
65
 
52
66
  def test_command_name_defaults_to_gitcode_for_python_module_on_windows(self):
53
67
  with mock.patch("platform.system", return_value="Windows"):
File without changes
File without changes
File without changes