gitcode-cli 0.14.1__tar.gz → 0.16.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.
- {gitcode_cli-0.14.1/gitcode_cli.egg-info → gitcode_cli-0.16.0}/PKG-INFO +10 -10
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/README.md +9 -9
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/__init__.py +1 -1
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/bin/gc-darwin-amd64 +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/bin/gc-darwin-arm64 +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/bin/gc-linux-amd64 +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/bin/gc-linux-arm64 +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/bin/gc-windows-amd64.exe +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/wrapper.py +13 -1
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0/gitcode_cli.egg-info}/PKG-INFO +10 -10
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gitcode_cli.egg-info/SOURCES.txt +1 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/pyproject.toml +1 -1
- gitcode_cli-0.16.0/tests/test_validate_ai_record.py +147 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/tests/test_wrapper.py +44 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/LICENSE +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/MANIFEST.in +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/__main__.py +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gc_cli/bin/.gitkeep +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gitcode_cli.egg-info/dependency_links.txt +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gitcode_cli.egg-info/entry_points.txt +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/gitcode_cli.egg-info/top_level.txt +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/setup.cfg +0 -0
- {gitcode_cli-0.14.1 → gitcode_cli-0.16.0}/tests/test_verify_remote_facts.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitcode-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.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>
|
|
@@ -91,10 +91,10 @@ npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@lat
|
|
|
91
91
|
CI、审计或版本复现可固定版本:
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@0.
|
|
94
|
+
npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@0.16.0 install
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
(scoped 坐标锁定形式:`npx --yes --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@0.
|
|
97
|
+
(scoped 坐标锁定形式:`npx --yes --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@0.16.0 install`)
|
|
98
98
|
|
|
99
99
|
不要使用 `npm i atomgit-cli` 或 `npm install atomgit-cli` 安装全局 CLI;这两条命令只会把包加入当前项目的 `node_modules`,不会更新 PATH 中已有的 `gitcode`。需要由 npm global prefix 管理入口时,可改用:
|
|
100
100
|
|
|
@@ -149,10 +149,10 @@ export PATH="$HOME/.local/bin:$PATH"
|
|
|
149
149
|
|
|
150
150
|
```bash
|
|
151
151
|
# 从 Releases 下载 .deb 包
|
|
152
|
-
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
152
|
+
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gc_0.16.0_amd64.deb
|
|
153
153
|
|
|
154
154
|
# 安装
|
|
155
|
-
sudo dpkg -i gc_0.
|
|
155
|
+
sudo dpkg -i gc_0.16.0_amd64.deb
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
@@ -161,10 +161,10 @@ DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
|
161
161
|
|
|
162
162
|
```bash
|
|
163
163
|
# 从 Releases 下载 .rpm 包
|
|
164
|
-
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
164
|
+
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gc-0.16.0-1.x86_64.rpm
|
|
165
165
|
|
|
166
166
|
# 安装
|
|
167
|
-
sudo rpm -i gc-0.
|
|
167
|
+
sudo rpm -i gc-0.16.0-1.x86_64.rpm
|
|
168
168
|
```
|
|
169
169
|
|
|
170
170
|
DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
@@ -180,7 +180,7 @@ source .venv/bin/activate # Linux/macOS
|
|
|
180
180
|
# .\.venv\Scripts\Activate.ps1 # Windows PowerShell
|
|
181
181
|
|
|
182
182
|
# 安装(一行命令)
|
|
183
|
-
pip install https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
183
|
+
pip install https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gitcode_cli-0.16.0-py3-none-any.whl
|
|
184
184
|
|
|
185
185
|
# Windows PowerShell 中推荐使用 gitcode,避免 gc 被内置 Get-Content 别名覆盖
|
|
186
186
|
gitcode version
|
|
@@ -210,7 +210,7 @@ source .venv/bin/activate # Linux/macOS
|
|
|
210
210
|
# .\.venv\Scripts\Activate.ps1 # Windows PowerShell
|
|
211
211
|
|
|
212
212
|
# 固定版本安装,避免 PyPI 尚未同步时安装旧版本
|
|
213
|
-
python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.
|
|
213
|
+
python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.16.0
|
|
214
214
|
|
|
215
215
|
# Windows PowerShell 中推荐使用 gitcode
|
|
216
216
|
gitcode version
|
|
@@ -277,7 +277,7 @@ brew upgrade gc
|
|
|
277
277
|
```
|
|
278
278
|
|
|
279
279
|
shell 补全(bash/zsh/fish)随安装自动配置,无需额外操作。
|
|
280
|
-
Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm
|
|
280
|
+
Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm 旧入口遮蔽。渠道检测会先解析 `gc`/`gitcode` 的软链再匹配 Homebrew 布局(Apple Silicon `/opt/homebrew`、Intel Mac `/usr/local`、Linuxbrew `/home/linuxbrew/.linuxbrew`),bin 目录软链与 Cellar 实路径均可识别。
|
|
281
281
|
|
|
282
282
|
### npm 更新与 PATH 诊断
|
|
283
283
|
|
|
@@ -62,10 +62,10 @@ npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@lat
|
|
|
62
62
|
CI、审计或版本复现可固定版本:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@0.
|
|
65
|
+
npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@0.16.0 install
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
(scoped 坐标锁定形式:`npx --yes --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@0.
|
|
68
|
+
(scoped 坐标锁定形式:`npx --yes --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@0.16.0 install`)
|
|
69
69
|
|
|
70
70
|
不要使用 `npm i atomgit-cli` 或 `npm install atomgit-cli` 安装全局 CLI;这两条命令只会把包加入当前项目的 `node_modules`,不会更新 PATH 中已有的 `gitcode`。需要由 npm global prefix 管理入口时,可改用:
|
|
71
71
|
|
|
@@ -120,10 +120,10 @@ export PATH="$HOME/.local/bin:$PATH"
|
|
|
120
120
|
|
|
121
121
|
```bash
|
|
122
122
|
# 从 Releases 下载 .deb 包
|
|
123
|
-
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
123
|
+
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gc_0.16.0_amd64.deb
|
|
124
124
|
|
|
125
125
|
# 安装
|
|
126
|
-
sudo dpkg -i gc_0.
|
|
126
|
+
sudo dpkg -i gc_0.16.0_amd64.deb
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
@@ -132,10 +132,10 @@ DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
|
132
132
|
|
|
133
133
|
```bash
|
|
134
134
|
# 从 Releases 下载 .rpm 包
|
|
135
|
-
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
135
|
+
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gc-0.16.0-1.x86_64.rpm
|
|
136
136
|
|
|
137
137
|
# 安装
|
|
138
|
-
sudo rpm -i gc-0.
|
|
138
|
+
sudo rpm -i gc-0.16.0-1.x86_64.rpm
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
@@ -151,7 +151,7 @@ source .venv/bin/activate # Linux/macOS
|
|
|
151
151
|
# .\.venv\Scripts\Activate.ps1 # Windows PowerShell
|
|
152
152
|
|
|
153
153
|
# 安装(一行命令)
|
|
154
|
-
pip install https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
154
|
+
pip install https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gitcode_cli-0.16.0-py3-none-any.whl
|
|
155
155
|
|
|
156
156
|
# Windows PowerShell 中推荐使用 gitcode,避免 gc 被内置 Get-Content 别名覆盖
|
|
157
157
|
gitcode version
|
|
@@ -181,7 +181,7 @@ source .venv/bin/activate # Linux/macOS
|
|
|
181
181
|
# .\.venv\Scripts\Activate.ps1 # Windows PowerShell
|
|
182
182
|
|
|
183
183
|
# 固定版本安装,避免 PyPI 尚未同步时安装旧版本
|
|
184
|
-
python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.
|
|
184
|
+
python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.16.0
|
|
185
185
|
|
|
186
186
|
# Windows PowerShell 中推荐使用 gitcode
|
|
187
187
|
gitcode version
|
|
@@ -248,7 +248,7 @@ brew upgrade gc
|
|
|
248
248
|
```
|
|
249
249
|
|
|
250
250
|
shell 补全(bash/zsh/fish)随安装自动配置,无需额外操作。
|
|
251
|
-
Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm
|
|
251
|
+
Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm 旧入口遮蔽。渠道检测会先解析 `gc`/`gitcode` 的软链再匹配 Homebrew 布局(Apple Silicon `/opt/homebrew`、Intel Mac `/usr/local`、Linuxbrew `/home/linuxbrew/.linuxbrew`),bin 目录软链与 Cellar 实路径均可识别。
|
|
252
252
|
|
|
253
253
|
### npm 更新与 PATH 诊断
|
|
254
254
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -77,6 +77,18 @@ def ensure_executable(binary_path: Path) -> None:
|
|
|
77
77
|
binary_path.chmod(0o755)
|
|
78
78
|
|
|
79
79
|
|
|
80
|
+
def detect_distribution() -> str:
|
|
81
|
+
"""Report the installation channel for the distribution env.
|
|
82
|
+
|
|
83
|
+
uv-managed tools run from .../uv/tools/<name>/... venvs; reporting "uv"
|
|
84
|
+
(instead of the blanket "pypi") makes `gc update` suggest
|
|
85
|
+
"uv tool upgrade" rather than running pip inside the uv-managed
|
|
86
|
+
environment — which is exactly what uv tells users not to do.
|
|
87
|
+
"""
|
|
88
|
+
prefix = str(Path(sys.prefix).resolve()).replace("\\", "/").lower()
|
|
89
|
+
return "uv" if "/uv/tools/" in prefix else "pypi"
|
|
90
|
+
|
|
91
|
+
|
|
80
92
|
def main() -> int:
|
|
81
93
|
"""Main entry point for the GitCode CLI command."""
|
|
82
94
|
try:
|
|
@@ -85,7 +97,7 @@ def main() -> int:
|
|
|
85
97
|
ensure_executable(binary_path)
|
|
86
98
|
env = os.environ.copy()
|
|
87
99
|
env.setdefault(COMMAND_NAME_ENV, get_command_name())
|
|
88
|
-
env.setdefault(DISTRIBUTION_ENV,
|
|
100
|
+
env.setdefault(DISTRIBUTION_ENV, detect_distribution())
|
|
89
101
|
env.setdefault(ENTRYPOINT_ENV, str(Path(sys.argv[0]).resolve()))
|
|
90
102
|
env.setdefault(BINARY_ENV, str(binary_path.resolve()))
|
|
91
103
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitcode-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.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>
|
|
@@ -91,10 +91,10 @@ npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@lat
|
|
|
91
91
|
CI、审计或版本复现可固定版本:
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@0.
|
|
94
|
+
npx --yes --ignore-scripts --registry=https://registry.npmjs.org atomgit-cli@0.16.0 install
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
(scoped 坐标锁定形式:`npx --yes --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@0.
|
|
97
|
+
(scoped 坐标锁定形式:`npx --yes --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@0.16.0 install`)
|
|
98
98
|
|
|
99
99
|
不要使用 `npm i atomgit-cli` 或 `npm install atomgit-cli` 安装全局 CLI;这两条命令只会把包加入当前项目的 `node_modules`,不会更新 PATH 中已有的 `gitcode`。需要由 npm global prefix 管理入口时,可改用:
|
|
100
100
|
|
|
@@ -149,10 +149,10 @@ export PATH="$HOME/.local/bin:$PATH"
|
|
|
149
149
|
|
|
150
150
|
```bash
|
|
151
151
|
# 从 Releases 下载 .deb 包
|
|
152
|
-
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
152
|
+
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gc_0.16.0_amd64.deb
|
|
153
153
|
|
|
154
154
|
# 安装
|
|
155
|
-
sudo dpkg -i gc_0.
|
|
155
|
+
sudo dpkg -i gc_0.16.0_amd64.deb
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
@@ -161,10 +161,10 @@ DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
|
161
161
|
|
|
162
162
|
```bash
|
|
163
163
|
# 从 Releases 下载 .rpm 包
|
|
164
|
-
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
164
|
+
wget https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gc-0.16.0-1.x86_64.rpm
|
|
165
165
|
|
|
166
166
|
# 安装
|
|
167
|
-
sudo rpm -i gc-0.
|
|
167
|
+
sudo rpm -i gc-0.16.0-1.x86_64.rpm
|
|
168
168
|
```
|
|
169
169
|
|
|
170
170
|
DEB/RPM packages install both `gc` and `gitcode`; on Linux they are equivalent.
|
|
@@ -180,7 +180,7 @@ source .venv/bin/activate # Linux/macOS
|
|
|
180
180
|
# .\.venv\Scripts\Activate.ps1 # Windows PowerShell
|
|
181
181
|
|
|
182
182
|
# 安装(一行命令)
|
|
183
|
-
pip install https://gitcode.com/atomgit-cli/cli/releases/download/v0.
|
|
183
|
+
pip install https://gitcode.com/atomgit-cli/cli/releases/download/v0.16.0/gitcode_cli-0.16.0-py3-none-any.whl
|
|
184
184
|
|
|
185
185
|
# Windows PowerShell 中推荐使用 gitcode,避免 gc 被内置 Get-Content 别名覆盖
|
|
186
186
|
gitcode version
|
|
@@ -210,7 +210,7 @@ source .venv/bin/activate # Linux/macOS
|
|
|
210
210
|
# .\.venv\Scripts\Activate.ps1 # Windows PowerShell
|
|
211
211
|
|
|
212
212
|
# 固定版本安装,避免 PyPI 尚未同步时安装旧版本
|
|
213
|
-
python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.
|
|
213
|
+
python -m pip install -i https://pypi.org/simple/ gitcode-cli==0.16.0
|
|
214
214
|
|
|
215
215
|
# Windows PowerShell 中推荐使用 gitcode
|
|
216
216
|
gitcode version
|
|
@@ -277,7 +277,7 @@ brew upgrade gc
|
|
|
277
277
|
```
|
|
278
278
|
|
|
279
279
|
shell 补全(bash/zsh/fish)随安装自动配置,无需额外操作。
|
|
280
|
-
Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm
|
|
280
|
+
Homebrew 同时提供 `gc` 与 `gitcode`;升级后可运行 `gitcode doctor install` 检查是否仍被 pip/npm 旧入口遮蔽。渠道检测会先解析 `gc`/`gitcode` 的软链再匹配 Homebrew 布局(Apple Silicon `/opt/homebrew`、Intel Mac `/usr/local`、Linuxbrew `/home/linuxbrew/.linuxbrew`),bin 目录软链与 Cellar 实路径均可识别。
|
|
281
281
|
|
|
282
282
|
### npm 更新与 PATH 诊断
|
|
283
283
|
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import importlib.util
|
|
2
|
+
import sys
|
|
3
|
+
import tempfile
|
|
4
|
+
import unittest
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
# validate-ai-record.py has a hyphen in its name so it cannot be imported
|
|
8
|
+
# normally; load it via importlib (same pattern as test_verify_remote_facts).
|
|
9
|
+
_spec = importlib.util.spec_from_file_location(
|
|
10
|
+
"validate_ai_record",
|
|
11
|
+
Path(__file__).parent.parent / "scripts" / "validate-ai-record.py",
|
|
12
|
+
)
|
|
13
|
+
var = importlib.util.module_from_spec(_spec)
|
|
14
|
+
sys.modules["validate_ai_record"] = var
|
|
15
|
+
_spec.loader.exec_module(var)
|
|
16
|
+
|
|
17
|
+
TEMPLATES = Path(__file__).parent.parent / "docs" / "ai-templates"
|
|
18
|
+
|
|
19
|
+
FILLED_RECORD = """## 背景与证据
|
|
20
|
+
|
|
21
|
+
### 问题
|
|
22
|
+
|
|
23
|
+
真实问题。
|
|
24
|
+
|
|
25
|
+
### 证据
|
|
26
|
+
|
|
27
|
+
- pkg/foo/bar.go:42
|
|
28
|
+
|
|
29
|
+
## 改动建议
|
|
30
|
+
|
|
31
|
+
按 A 方案修复。
|
|
32
|
+
|
|
33
|
+
## 验收标准
|
|
34
|
+
|
|
35
|
+
输出与文档一致。
|
|
36
|
+
|
|
37
|
+
## 影响范围
|
|
38
|
+
|
|
39
|
+
pkg/foo/
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class SectionContentTests(unittest.TestCase):
|
|
44
|
+
"""record-mode section semantics for heading-style fields (issue 629).
|
|
45
|
+
|
|
46
|
+
These branches are exercised by CI only through this file: the make
|
|
47
|
+
targets run template mode, so a regression in section_content would
|
|
48
|
+
otherwise be completely silent.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def test_body_returns_real_content_until_next_heading(self):
|
|
52
|
+
lines = ["## 一段", "", "真实内容", "## 二段", "其他"]
|
|
53
|
+
self.assertEqual(var.section_content(lines, "## 一段"), "真实内容")
|
|
54
|
+
|
|
55
|
+
def test_comments_do_not_count_as_content(self):
|
|
56
|
+
lines = ["## 一段", "<!-- guidance -->", ""]
|
|
57
|
+
self.assertEqual(var.section_content(lines, "## 一段"), "")
|
|
58
|
+
|
|
59
|
+
def test_whole_line_placeholder_does_not_count_as_content(self):
|
|
60
|
+
lines = ["## 一段", "(问题描述)"]
|
|
61
|
+
self.assertEqual(var.section_content(lines, "## 一段"), "")
|
|
62
|
+
|
|
63
|
+
def test_list_form_placeholder_does_not_count_as_content(self):
|
|
64
|
+
# The evidence section's placeholder ships as a list item; the
|
|
65
|
+
# placeholder rule must cover both shapes (fb27983).
|
|
66
|
+
lines = ["## 一段", "- (file:line / 命令输出 / 引用)"]
|
|
67
|
+
self.assertEqual(var.section_content(lines, "## 一段"), "")
|
|
68
|
+
|
|
69
|
+
def test_mixed_list_line_with_parenthetical_still_counts(self):
|
|
70
|
+
# Real evidence lines keep their content: only entire values wrapped
|
|
71
|
+
# in full-width parens are placeholders.
|
|
72
|
+
lines = ["## 一段", "- pkg/foo/bar.go:42(实证)"]
|
|
73
|
+
self.assertEqual(var.section_content(lines, "## 一段"), "- pkg/foo/bar.go:42(实证)")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class ParseFieldsTests(unittest.TestCase):
|
|
77
|
+
def test_list_and_heading_fields_coexist(self):
|
|
78
|
+
lines = ["- 列表字段: 值", "## 标题字段", "- 另一列表: v"]
|
|
79
|
+
found = var.parse_fields(lines)
|
|
80
|
+
self.assertEqual(found["列表字段"], "值")
|
|
81
|
+
self.assertEqual(found["另一列表"], "v")
|
|
82
|
+
self.assertIn("## 标题字段", found)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class ValidateRecordModeTests(unittest.TestCase):
|
|
86
|
+
def _validate(self, text: str, kind: str = "issue-create"):
|
|
87
|
+
with tempfile.NamedTemporaryFile(
|
|
88
|
+
"w", suffix=".md", delete=False, encoding="utf-8"
|
|
89
|
+
) as handle:
|
|
90
|
+
handle.write(text)
|
|
91
|
+
path = handle.name
|
|
92
|
+
try:
|
|
93
|
+
return var.validate(Path(path), kind, "record")
|
|
94
|
+
finally:
|
|
95
|
+
Path(path).unlink()
|
|
96
|
+
|
|
97
|
+
def test_filled_record_passes(self):
|
|
98
|
+
self.assertEqual(self._validate(FILLED_RECORD), [])
|
|
99
|
+
|
|
100
|
+
def test_emptied_section_is_reported(self):
|
|
101
|
+
broken = FILLED_RECORD.replace("按 A 方案修复。", "")
|
|
102
|
+
self.assertIn("empty value: ## 改动建议", self._validate(broken))
|
|
103
|
+
|
|
104
|
+
def test_comment_only_section_is_reported(self):
|
|
105
|
+
broken = FILLED_RECORD.replace(
|
|
106
|
+
"按 A 方案修复。", "<!-- guidance only -->"
|
|
107
|
+
)
|
|
108
|
+
self.assertIn("empty value: ## 改动建议", self._validate(broken))
|
|
109
|
+
|
|
110
|
+
def test_unreplaced_placeholder_is_reported(self):
|
|
111
|
+
broken = FILLED_RECORD.replace("按 A 方案修复。", "(待填)")
|
|
112
|
+
self.assertIn("empty value: ## 改动建议", self._validate(broken))
|
|
113
|
+
|
|
114
|
+
def test_mixed_draft_with_evidence_placeholder_is_reported(self):
|
|
115
|
+
# Every section filled except the evidence placeholder: the exact
|
|
116
|
+
# partial-draft bypass that three reviewers converged on.
|
|
117
|
+
broken = FILLED_RECORD.replace(
|
|
118
|
+
"- pkg/foo/bar.go:42", "- (file:line / 命令输出 / 引用)"
|
|
119
|
+
)
|
|
120
|
+
self.assertIn("empty value: ### 证据", self._validate(broken))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class AsShippedTemplateTests(unittest.TestCase):
|
|
124
|
+
"""The factory behaviour: templates as shipped must fail record mode,
|
|
125
|
+
matching the ten list-style kinds (whose empty fields always did)."""
|
|
126
|
+
|
|
127
|
+
def test_issue_create_template_as_shipped_fails_record(self):
|
|
128
|
+
errors = var.validate(
|
|
129
|
+
TEMPLATES / "issue-create.md", "issue-create", "record"
|
|
130
|
+
)
|
|
131
|
+
self.assertTrue(errors, "as-shipped template must not pass record mode")
|
|
132
|
+
|
|
133
|
+
def test_list_style_template_as_shipped_fails_record(self):
|
|
134
|
+
errors = var.validate(
|
|
135
|
+
TEMPLATES / "pr-self-check.md", "pr-self-check", "record"
|
|
136
|
+
)
|
|
137
|
+
self.assertTrue(errors, "as-shipped list template must not pass record mode")
|
|
138
|
+
|
|
139
|
+
def test_issue_create_template_passes_template_mode(self):
|
|
140
|
+
errors = var.validate(
|
|
141
|
+
TEMPLATES / "issue-create.md", "issue-create", "template"
|
|
142
|
+
)
|
|
143
|
+
self.assertEqual(errors, [])
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
if __name__ == "__main__":
|
|
147
|
+
unittest.main()
|
|
@@ -84,3 +84,47 @@ class WrapperTests(unittest.TestCase):
|
|
|
84
84
|
|
|
85
85
|
if __name__ == "__main__":
|
|
86
86
|
unittest.main()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class DetectDistributionTests(unittest.TestCase):
|
|
90
|
+
def test_uv_tool_venv_reports_uv(self):
|
|
91
|
+
for prefix in (
|
|
92
|
+
"/home/u/.local/share/uv/tools/gitcode-cli",
|
|
93
|
+
"C:\\Users\\u\\AppData\\Roaming\\uv\\tools\\gc",
|
|
94
|
+
"/home/u/UV/Tools/gitcode-cli", # custom UV_TOOL_DIR, upper case
|
|
95
|
+
):
|
|
96
|
+
with mock.patch("sys.prefix", prefix):
|
|
97
|
+
with mock.patch("pathlib.Path.resolve", return_value=Path(prefix)):
|
|
98
|
+
self.assertEqual(wrapper.detect_distribution(), "uv", prefix)
|
|
99
|
+
|
|
100
|
+
def test_ordinary_venv_reports_pypi(self):
|
|
101
|
+
for prefix in ("/usr", "/home/u/venv", "C:\\Users\\u\\venv"):
|
|
102
|
+
with mock.patch("sys.prefix", prefix):
|
|
103
|
+
with mock.patch("pathlib.Path.resolve", return_value=Path(prefix)):
|
|
104
|
+
self.assertEqual(wrapper.detect_distribution(), "pypi", prefix)
|
|
105
|
+
|
|
106
|
+
def test_main_declares_uv_channel_for_uv_tools(self):
|
|
107
|
+
captured = {}
|
|
108
|
+
|
|
109
|
+
def fake_run(argv, **kwargs):
|
|
110
|
+
captured.update(kwargs.get("env") or {})
|
|
111
|
+
return mock.Mock(returncode=0)
|
|
112
|
+
|
|
113
|
+
binary = Path("/tmp/fake-gc")
|
|
114
|
+
with mock.patch("gc_cli.wrapper.get_binary_path", return_value=binary):
|
|
115
|
+
with mock.patch("gc_cli.wrapper.ensure_executable"):
|
|
116
|
+
with mock.patch("subprocess.run", side_effect=fake_run):
|
|
117
|
+
with mock.patch("sys.argv", ["gitcode", "version"]):
|
|
118
|
+
with mock.patch(
|
|
119
|
+
"sys.prefix", "/home/u/.local/share/uv/tools/gitcode-cli"
|
|
120
|
+
):
|
|
121
|
+
with mock.patch(
|
|
122
|
+
"pathlib.Path.resolve", return_value=Path("/home/u/.local/share/uv/tools/gitcode-cli")
|
|
123
|
+
):
|
|
124
|
+
wrapper.main()
|
|
125
|
+
|
|
126
|
+
self.assertEqual(captured.get(wrapper.DISTRIBUTION_ENV), "uv")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|