feat(list): issue/pr/branch/release +list 新增 --all 自动翻页(翻页助手对齐生产 API 响应形状) #338

Closed
Taoyouce wants to merge 0 commits from Taoyouce/gitlink-cli:feat/list-all-pagination into master
Contributor

问题

  1. issue +list / pr +list / branch +list / release +list 一次只能取一页,用户或 AI Agent 想拿全量列表必须手动循环 --page
  2. 代码中已有的翻页助手 Client.PaginateAll 只识别 data 包裹键,而生产 API 的列表响应实际用资源名包裹数组({"total_count":N,"issues":[...]}"pulls""branches""releases",均经生产实测确认),导致它在真实端点上退化为单对象返回——事实上是从未被任何命令使用的死代码。

修复 / 功能

  • internal/client 新增 PaginateAllKey(path, params, listKey):按资源键提取数组;listKey 为空时自动探测(顶层数组 / data 包裹 / 唯一数组字段)。遵循 total_count 达到即停,另设最大页数护栏防止忽略 page 参数的端点死循环。PaginateAll 保持原签名委托实现。
  • 四个 list 命令新增 --all 布尔参数(默认 false),输出与单页响应同构:{"total_count": N, "<资源名>": [...]}issue +list --all 同样应用 number/database_id 规范化。
  • 中英文 i18n 新增 flag.all 文案;doc/changes 附变更说明。

测试

  • internal/client/pagination_test.go 6 个用例:多页合并、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 条
## 问题 1. `issue +list` / `pr +list` / `branch +list` / `release +list` 一次只能取一页,用户或 AI Agent 想拿全量列表必须手动循环 `--page`。 2. 代码中已有的翻页助手 `Client.PaginateAll` 只识别 `data` 包裹键,而生产 API 的列表响应实际用**资源名**包裹数组(`{"total_count":N,"issues":[...]}`、`"pulls"`、`"branches"`、`"releases"`,均经生产实测确认),导致它在真实端点上退化为单对象返回——事实上是从未被任何命令使用的死代码。 ## 修复 / 功能 - `internal/client` 新增 `PaginateAllKey(path, params, listKey)`:按资源键提取数组;`listKey` 为空时自动探测(顶层数组 / `data` 包裹 / 唯一数组字段)。遵循 `total_count` 达到即停,另设最大页数护栏防止忽略 page 参数的端点死循环。`PaginateAll` 保持原签名委托实现。 - 四个 list 命令新增 `--all` 布尔参数(默认 false),输出与单页响应同构:`{"total_count": N, "<资源名>": [...]}`;`issue +list --all` 同样应用 number/database_id 规范化。 - 中英文 i18n 新增 `flag.all` 文案;doc/changes 附变更说明。 ## 测试 - `internal/client/pagination_test.go` 6 个用例:多页合并、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 条
Taoyouce added 1 commit 2026-07-06 06:07:38 +08:00
b82378bb4e feat(list): --all 自动翻页,翻页助手对齐生产 API 资源键包裹形状
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 06:21:58 +08:00
343c5494fb feat(list): --all 推广至 milestone/org/repo/search,共 9 个分页 list 命令;总数字段兼容 count
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 06:36:28 +08:00
4435dd251d feat(list): label/member +list 补齐分页与 --all;member list 改走 v1 端点修复非管理员 403
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 06:40:38 +08:00
2d9789b060 docs(readme): --all 自动翻页示例(中英)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 06:47:55 +08:00
a6679bf787 feat(list): webhook +list 补齐分页与 --all(探针实测确认端点分页)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 06:53:42 +08:00
6104ab53f9 chore(webhook): --all 文案接入 i18n flag.all
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 06:56:05 +08:00
d328a1d97b feat(issue): 新增 issue +comments 读评论流(journals 分页 + --all,对标 gh issue view --comments)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 06:58:14 +08:00
8958a686a6 feat(pr): 新增 pr +comments 读 PR 评论流(端点实测忽略分页参数,不暴露假分页 flag)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 07:03:29 +08:00
1ca60f9280 feat(list): 新增 tag +list 命令组、watchers/stargazers 分页;修复翻页助手服务端封顶 limit 丢数据 bug
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 07:06:10 +08:00
78fa470b94 feat(list): 新增 commit +list 命令组与 repo +forks(分页 + --all)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 07:07:40 +08:00
ce8db5912e feat(pr): 新增 pr +commits 读 PR 提交列表(端点实测忽略分页参数)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 07:10:15 +08:00
e225b86e80 feat(commit): 新增 commit +view 单提交详情;README 中英补新命令示例
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 07:13:08 +08:00
2a92ac33dd feat(org): org +members 支持 --all 自动翻页(资源键 organization_users)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 07:15:01 +08:00
524bf43acc feat(org): 新增 org +repos 组织仓库列表(分页 + --all)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-06 07:17:41 +08:00
dfa127c27a test: tag/commit 命令组补 httptest 单测(分页参数、--all 合并、--ref sha、view 路径)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-07 22:32:35 +08:00
Taoyouce added 1 commit 2026-07-08 23:04:32 +08:00
99e536226a feat(tag): add +view with list-scan fallback
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>
Taoyouce added 1 commit 2026-07-11 00:40:24 +08:00
Taoyouce added 1 commit 2026-07-11 01:38:40 +08:00
466a3d5fd9 test(client): 新增 PaginateAllKey 基准测试(模拟每页延迟,覆盖并发翻页路径)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
wbtiger closed this pull request 2026-07-14 22:56:47 +08:00
wbtiger reopened this pull request 2026-07-14 23:02:08 +08:00
wbtiger closed this pull request 2026-07-14 23:05:22 +08:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Gitlink/gitlink-cli#338
No description provided.