forked from Gitlink/gitlink-cli
feat(output): 全局 --query/-q 点分路径输出字段提取(零依赖,对标 gh --jq) #7
Loading…
Reference in New Issue
No description provided.
Delete Branch "test-import/pr-6"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
动机
对标
gh --jq:Agent 与 shell 脚本消费 CLI 输出时经常只需单个字段(最新 commit sha、issue 总数等),此前必须依赖外部 jq 或自行解析完整 JSON 信封。本 PR 新增零依赖的点分路径提取,纯 Go 标准库实现,不引入任何第三方 JSON 查询库(避免供应链风险)。行为
--query/-q,对所有命令生效-q data.commits.0.sha、-q data.total_issues_count生产实测
issue +list --limit 2 -q data.issues.0.subject→ 裸标题字符串issue +list -q data.total_issues_count→ 4197-q data.issues.0.name→ 报错并列出全部可用键(含 subject)测试
internal/output/query_test.go 6 个单测;全量 go test/vet/gofmt 通过。i18n 中英文案齐备。
- Add pr +reviews to list reviews for a pull request (with status filter) - Add pr +review to create a review (comment/approve/reject) - Uses v1 API: /v1/{owner}/{repo}/pulls/{index}/reviews - Includes tests for both list and create operations Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1. shortcuts/pr/pr.go — 核心逻辑 +diff 命令替换: 旧实现:与 +files 完全相同,调用 /pulls/{id}/files(只返回文件列表) 新实现:两步调用 GET /v1/{owner}/{repo}/pulls/{id}/versions → 取最新版本 ID GET /v1/{owner}/{repo}/pulls/{id}/versions/{version_id}/diff → 获取逐行 diff 新增参数: --file / -f — 过滤特定文件的 diff --stat — 仅显示统计摘要 新增函数: getLatestVersionID() — 获取 PR 最新版本 ID formatDiffStat() — 提取增删统计摘要 2. internal/output/formatter.go — Diff 渲染 isDiffData() — 通过检测 files[].sections 区分 diff 数据和普通文件列表 printDiffTable() — 以 git diff 风格渲染:diff --git 头、hunk header、增删行 修改 printTable() 路由,自动检测并走 diff 渲染分支 3. shortcuts/pr/pr_test.go — 新增 5 个测试 测试用例 验证内容 TestPRDiffFetchesVersionThenDiff 两步调用完整流程 TestPRDiffWithFileFilter --file 参数传递 filepath 查询参数 TestPRDiffStatMode --stat 模式只输出统计 TestPRDiffFailsWhenNoVersions 无版本时返回友好错误 TestPRDiffFailsWhenPRNotFound PR 不存在时正确处理 404 4. Skill 文档更新 SKILL.md — 更新 +diff 描述、新增使用示例、更新注意事项 gitlink-pr-files.md — 完整重写,明确 +files 和 +diff 的区别新增功能参数 gitlink-cli search +issues --keyword "登录失败" # 必填:搜索关键词 --category opened # 可选:all/opened/closed --assignee 42 # 可选:按负责人 ID --author 10 # 可选:按创建人 ID --milestone 5 # 可选:按里程碑 ID --tag 1,2 # 可选:按标签 ID --sort-by created_on # 可选:排序字段 --sort-dir asc # 可选:排序方向 API 调用 GET /api/v1/{owner}/{repo}/issues?keyword=xxx&category=opened&assigner_id=42&sort_by=issues.updated_onclose 命令 API URL 误拼为 {repo_path}/{owner}/milestones/{id}/update_status(Owner 重复、Repo 丢失、缺 /v1),修正为 /v1/{owner}/{repo}/milestones/{id}/update_status;新增 TestMilestoneClose 回归测试。 Co-Authored-By: Claude <noreply@anthropic.com>新增 server 子命令启动 HTTP 服务(:8080),提供 /api/scenarios、/api/run、/api/result/{key}、/api/health;前端含仪表盘(index)、独立结果页(result)、热点追踪页(hotspot),6 科研场景一键运行与可视化。在 cmd/root.go 注册子命令。 Co-Authored-By: Claude <noreply@anthropic.com>Pull request closed