feat(list): issue/pr/branch/release +list 新增 --all 自动翻页(翻页助手对齐生产 API 响应形状) #338
Loading…
Reference in New Issue
No description provided.
Delete Branch "Taoyouce/gitlink-cli:feat/list-all-pagination"
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?
问题
issue +list/pr +list/branch +list/release +list一次只能取一页,用户或 AI Agent 想拿全量列表必须手动循环--page。Client.PaginateAll只识别data包裹键,而生产 API 的列表响应实际用资源名包裹数组({"total_count":N,"issues":[...]}、"pulls"、"branches"、"releases",均经生产实测确认),导致它在真实端点上退化为单对象返回——事实上是从未被任何命令使用的死代码。修复 / 功能
internal/client新增PaginateAllKey(path, params, listKey):按资源键提取数组;listKey为空时自动探测(顶层数组 /data包裹 / 唯一数组字段)。遵循total_count达到即停,另设最大页数护栏防止忽略 page 参数的端点死循环。PaginateAll保持原签名委托实现。--all布尔参数(默认 false),输出与单页响应同构:{"total_count": N, "<资源名>": [...]};issue +list --all同样应用 number/database_id 规范化。flag.all文案;doc/changes 附变更说明。测试
internal/client/pagination_test.go6 个用例:多页合并、total_count 截断(模拟忽略 page 的异常端点,验证不会死循环)、data 包裹、唯一数组字段自动探测、单对象回退、指定键缺失回退。shortcuts/issue新增--all端到端用例验证请求页序列与合并。go test ./.../go vet/gofmt全绿。生产实测(gitlink.org.cn)
issue +list --state all --all --limit 5:19 条全量合并(4 页)pr +list --state all --all --limit 5:337 条全量合并(68 页)branch +list --all --limit 5:7 条release +list --all --limit 5(forgeplus 仓库):15 条tag +view -n <name> wraps GET /v1/:owner/:repo/tags/:name. In production the show endpoint's tag-existence precheck (gitea-hat tag_name_set) rejects tags that the paginated list returns ('标签不存在!' even for a tag visible in tags.json), so on error the command falls back to scanning the paginated list for the requested name and emits the matching entry. Production-reproduced the precheck bug and verified the fallback returns the correct tag. 2 unit tests cover the direct path and the fallback. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Pull request closed