From a6679bf787a3bbdfc56c9d5e5ffaeda0a63f941d Mon Sep 17 00:00:00 2001 From: laurencewannamaker Date: Sun, 5 Jul 2026 22:48:38 +0000 Subject: [PATCH] =?UTF-8?q?feat(list):=20webhook=20+list=20=E8=A1=A5?= =?UTF-8?q?=E9=BD=90=E5=88=86=E9=A1=B5=E4=B8=8E=20--all=EF=BC=88=E6=8E=A2?= =?UTF-8?q?=E9=92=88=E5=AE=9E=E6=B5=8B=E7=A1=AE=E8=AE=A4=E7=AB=AF=E7=82=B9?= =?UTF-8?q?=E5=88=86=E9=A1=B5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- README.md | 2 +- README.zh-CN.md | 2 +- doc/changes/list-all-pagination.md | 12 +++++++----- shortcuts/webhook/webhook.go | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 798573f..9c911be 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/README.zh-CN.md b/README.zh-CN.md index 7fad292..88d6229 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -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 diff --git a/doc/changes/list-all-pagination.md b/doc/changes/list-all-pagination.md index 88d1f24..54b0145 100644 --- a/doc/changes/list-all-pagination.md +++ b/doc/changes/list-all-pagination.md @@ -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)。 diff --git a/shortcuts/webhook/webhook.go b/shortcuts/webhook/webhook.go index 7d0574a..2fef25c 100644 --- a/shortcuts/webhook/webhook.go +++ b/shortcuts/webhook/webhook.go @@ -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 }