feat(list): webhook +list 补齐分页与 --all(探针实测确认端点分页)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
2d9789b060
commit
a6679bf787
|
|
@ -325,7 +325,7 @@ gitlink-cli member +invite-link --owner Gitlink --repo forgeplus --role develope
|
|||
gitlink-cli issue +list --owner Gitlink --repo forgeplus
|
||||
|
||||
# Fetch all pages automatically (works on all paginated list commands:
|
||||
# issue/pr/branch/release/milestone/org/repo/label/member +list, search +repos/+users)
|
||||
# issue/pr/branch/release/milestone/org/repo/label/member/webhook +list, search +repos/+users)
|
||||
gitlink-cli issue +list --owner Gitlink --repo forgeplus --all
|
||||
|
||||
# Create an issue
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ gitlink-cli member +invite-link --owner Gitlink --repo forgeplus --role develope
|
|||
gitlink-cli issue +list --owner Gitlink --repo forgeplus
|
||||
|
||||
# 自动翻页拉取全部(适用于所有可分页 list 命令:
|
||||
# issue/pr/branch/release/milestone/org/repo/label/member +list、search +repos/+users)
|
||||
# issue/pr/branch/release/milestone/org/repo/label/member/webhook +list、search +repos/+users)
|
||||
gitlink-cli issue +list --owner Gitlink --repo forgeplus --all
|
||||
|
||||
# 创建 Issue
|
||||
|
|
|
|||
|
|
@ -16,21 +16,23 @@
|
|||
- 遵循 `total_count`:达到总数即停止;另设最大页数护栏,防止
|
||||
忽略 `page` 参数的端点造成死循环。
|
||||
- `PaginateAll` 保持原签名,委托给 `PaginateAllKey`。
|
||||
- 十一个分页 list 命令新增 `--all` 布尔参数(默认 false):
|
||||
- 十二个分页 list 命令新增 `--all` 布尔参数(默认 false):
|
||||
- `issue +list --all`(合并结果同样应用 number/database_id 规范化)
|
||||
- `pr +list --all`、`branch +list --all`、`release +list --all`
|
||||
- `milestone +list --all`、`org +list --all`、`repo +list --all`
|
||||
- `search +repos --all`、`search +users --all`
|
||||
- `label +list --all`、`member +list --all`
|
||||
- `label +list --all`、`member +list --all`、`webhook +list --all`
|
||||
- 对应资源键:`issues`/`pulls`/`branches`/`releases`/`milestones`/
|
||||
`organizations`/`projects`/`users`/`issue_tags`/`collaborators`
|
||||
`organizations`/`projects`/`users`/`issue_tags`/`collaborators`/`webhooks`
|
||||
(均生产实测确认)
|
||||
- 输出与单页响应同构:`{"total_count": N, "<资源名>": [...]}`。
|
||||
- 总数字段兼容 `total_count` 与 `count`(如 `/users/:login/projects`)。
|
||||
- 修复两个既有分页语义缺口(均生产实测确认端点本身分页):
|
||||
- 修复三个既有分页语义缺口(均生产实测确认端点本身分页):
|
||||
- `label +list` 完全没有 `--page/--limit`(端点实际返回 `total_count`),现已补齐;
|
||||
- `member +list` 既无分页又走遗留路径(非管理员直接 403),现改走
|
||||
`/v1/:owner/:repo/collaborators`(支持分页且普通成员可读)。
|
||||
`/v1/:owner/:repo/collaborators`(支持分页且普通成员可读);
|
||||
- `webhook +list` 完全没有 `--page/--limit`(探针实测:建 3 个 webhook 后
|
||||
`page=2&limit=1` 返回第二条,确认端点分页),现已补齐。
|
||||
- 未加 `--all` 的 list 端点均经生产验证为非分页或未部署:
|
||||
`licenses`/`ignores` 返回全量数组;`pm/pipelines` 404 未部署;
|
||||
`pipeline +runs` 用 `total_data` 非标准包裹;dataset 端点未部署(平台 issue #144255)。
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package webhook
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gitlink-org/gitlink-cli/internal/i18n"
|
||||
|
|
@ -29,11 +30,26 @@ func Shortcuts(translators ...*i18n.Translator) []*common.Shortcut {
|
|||
{
|
||||
Name: "list",
|
||||
Description: tr.T("cmd.webhook.list.short"),
|
||||
Flags: []common.Flag{
|
||||
{Name: "page", Short: "p", Usage: "Page number", Default: "1"},
|
||||
{Name: "limit", Short: "l", Usage: "Items per page", Default: "20"},
|
||||
{Name: "all", Usage: "Fetch all pages automatically (ignores --page)", Bool: true, Default: "false"},
|
||||
},
|
||||
Run: func(ctx *common.RuntimeContext) error {
|
||||
if err := ctx.ResolveOwnerRepo(); err != nil {
|
||||
return err
|
||||
}
|
||||
env, err := ctx.CallAPI("GET", webhookPath(ctx), nil)
|
||||
q := url.Values{}
|
||||
q.Set("page", ctx.Arg("page"))
|
||||
q.Set("limit", ctx.Arg("limit"))
|
||||
if ctx.Arg("all") == "true" {
|
||||
items, err := ctx.PaginateAllKey(webhookPath(ctx), q, "webhooks")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.Output(common.NewListEnvelope("webhooks", items))
|
||||
}
|
||||
env, err := ctx.CallAPIWithQuery("GET", webhookPath(ctx), q)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue