From 524bf43accdee72fb835f13ad7bd4d7859af8bd9 Mon Sep 17 00:00:00 2001 From: laurencewannamaker Date: Sun, 5 Jul 2026 23:15:44 +0000 Subject: [PATCH] =?UTF-8?q?feat(org):=20=E6=96=B0=E5=A2=9E=20org=20+repos?= =?UTF-8?q?=20=E7=BB=84=E7=BB=87=E4=BB=93=E5=BA=93=E5=88=97=E8=A1=A8?= =?UTF-8?q?=EF=BC=88=E5=88=86=E9=A1=B5=20+=20--all=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> --- doc/changes/list-all-pagination.md | 5 ++++- internal/i18n/locales/en-US.json | 1 + internal/i18n/locales/zh-CN.json | 1 + shortcuts/org/org.go | 29 +++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/doc/changes/list-all-pagination.md b/doc/changes/list-all-pagination.md index 48d5a91..36ecc06 100644 --- a/doc/changes/list-all-pagination.md +++ b/doc/changes/list-all-pagination.md @@ -16,7 +16,7 @@ - 遵循 `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` @@ -26,6 +26,9 @@ - `tag +list --all`、`commit +list --all`(新增命令组,见下) - `repo +watchers/+stargazers/+forks --all`、`org +members --all` (资源键 `organization_users`,生产实测 gitlink 组织 71 名成员全量合并) + - `org +repos --all`(新增子命令:组织仓库列表 + `/organizations/:name/projects`,此前只能裸 api 访问; + 生产实测 gitlink 组织 28 个仓库全量合并) - 对应资源键:`issues`/`pulls`/`branches`/`releases`/`milestones`/ `organizations`/`projects`/`users`/`issue_tags`/`collaborators`/`webhooks` (均生产实测确认) diff --git a/internal/i18n/locales/en-US.json b/internal/i18n/locales/en-US.json index af61dc0..49ae93c 100644 --- a/internal/i18n/locales/en-US.json +++ b/internal/i18n/locales/en-US.json @@ -52,6 +52,7 @@ "cmd.org.info.short": "Show organization details", "cmd.org.list.short": "List organizations", "cmd.org.members.short": "List organization members", + "cmd.org.repos.short": "List repositories of an organization", "cmd.org.short": "Organization operations", "cmd.pr.close.short": "Close a pull request", "cmd.pr.comment.short": "Add a comment to a pull request", diff --git a/internal/i18n/locales/zh-CN.json b/internal/i18n/locales/zh-CN.json index af3aac9..a257cf7 100644 --- a/internal/i18n/locales/zh-CN.json +++ b/internal/i18n/locales/zh-CN.json @@ -52,6 +52,7 @@ "cmd.org.info.short": "显示组织详情", "cmd.org.list.short": "列出组织", "cmd.org.members.short": "列出组织成员", + "cmd.org.repos.short": "列出组织下的仓库", "cmd.org.short": "组织操作", "cmd.pr.close.short": "关闭拉取请求", "cmd.pr.comment.short": "给拉取请求添加评论", diff --git a/shortcuts/org/org.go b/shortcuts/org/org.go index cf27900..8f77ead 100644 --- a/shortcuts/org/org.go +++ b/shortcuts/org/org.go @@ -80,6 +80,35 @@ func Shortcuts(translators ...*i18n.Translator) []*common.Shortcut { return ctx.Output(env) }, }, + { + Name: "repos", + Description: tr.T("cmd.org.repos.short"), + Flags: []common.Flag{ + {Name: "id", Short: "i", Usage: tr.T("flag.org.id"), Required: true}, + {Name: "page", Short: "p", Usage: tr.T("flag.page"), Default: "1"}, + {Name: "limit", Short: "l", Usage: tr.T("flag.limit"), Default: "20"}, + {Name: "all", Usage: tr.T("flag.all"), Bool: true, Default: "false"}, + }, + Run: func(ctx *common.RuntimeContext) error { + id, _ := ctx.RequireArg("id") + path := fmt.Sprintf("/organizations/%s/projects", id) + q := url.Values{} + q.Set("page", ctx.Arg("page")) + q.Set("limit", ctx.Arg("limit")) + if ctx.Arg("all") == "true" { + items, err := ctx.PaginateAllKey(path, q, "projects") + if err != nil { + return err + } + return ctx.Output(common.NewListEnvelope("projects", items)) + } + env, err := ctx.CallAPIWithQuery("GET", path, q) + if err != nil { + return err + } + return ctx.Output(env) + }, + }, { Name: "create", Description: tr.T("cmd.org.create.short"),