From 23a478bd69d75a3eb9fabbb50a02db1f4c90fc32 Mon Sep 17 00:00:00 2001 From: wangyue789 Date: Sun, 24 May 2026 22:27:00 +0800 Subject: [PATCH] feat(issue): add authors shortcut --- README.md | 3 +++ README.zh-CN.md | 3 +++ shortcuts/issue/issue.go | 21 ++++++++++++++++ shortcuts/issue/issue_test.go | 23 +++++++++++++++++ skills/gitlink-issue/SKILL.md | 4 +++ .../references/gitlink-issue-authors.md | 25 +++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 skills/gitlink-issue/references/gitlink-issue-authors.md diff --git a/README.md b/README.md index c04b63d..0148d95 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,9 @@ gitlink-cli issue +comment --owner Gitlink --repo forgeplus -i 123 -b "Fixed" # List issue assigners gitlink-cli issue +assigners --owner Gitlink --repo forgeplus + +# List issue authors +gitlink-cli issue +authors --owner Gitlink --repo forgeplus ``` ### Pull Requests diff --git a/README.zh-CN.md b/README.zh-CN.md index b8c0ae2..62c473d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -212,6 +212,9 @@ gitlink-cli issue +comment --owner Gitlink --repo forgeplus -i 123 -b "已修复 # 列出 Issue 负责人 gitlink-cli issue +assigners --owner Gitlink --repo forgeplus + +# 列出 Issue 发布人 +gitlink-cli issue +authors --owner Gitlink --repo forgeplus ``` ### Pull Request diff --git a/shortcuts/issue/issue.go b/shortcuts/issue/issue.go index e6c65f0..7c0bc68 100644 --- a/shortcuts/issue/issue.go +++ b/shortcuts/issue/issue.go @@ -244,6 +244,27 @@ func Shortcuts() []*common.Shortcut { return ctx.Output(env) }, }, + { + Name: "authors", + Description: "List issue authors", + Flags: []common.Flag{ + {Name: "keyword", Short: "k", Usage: "Search keyword"}, + }, + Run: func(ctx *common.RuntimeContext) error { + if err := ctx.ResolveOwnerRepo(); err != nil { + return err + } + q := url.Values{} + if keyword := ctx.Arg("keyword"); keyword != "" { + q.Set("keyword", keyword) + } + env, err := ctx.CallAPIWithQuery("GET", v1RepoPath(ctx)+"/issue_authors", q) + if err != nil { + return err + } + return ctx.Output(env) + }, + }, } } diff --git a/shortcuts/issue/issue_test.go b/shortcuts/issue/issue_test.go index b412409..661a4de 100644 --- a/shortcuts/issue/issue_test.go +++ b/shortcuts/issue/issue_test.go @@ -154,6 +154,29 @@ func TestIssueAssignersShortcutWithKeyword(t *testing.T) { } } +func TestIssueAuthorsShortcutWithKeyword(t *testing.T) { + server := newIssueTestServer(t, func(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" || r.URL.Path != "/v1/owner/repo/issue_authors.json" { + t.Fatalf("unexpected request: %s %s", r.Method, r.URL.Path) + } + assertEqual(t, r.URL.Query().Get("keyword"), "bob") + writeJSON(t, w, map[string]interface{}{ + "total_count": 1, + "authors": []map[string]interface{}{ + {"id": 8, "name": "Bob", "login": "bob"}, + }, + }) + }) + defer server.Close() + + err := runIssueShortcut(t, server, "authors", map[string]string{ + "keyword": "bob", + }) + if err != nil { + t.Fatalf("authors shortcut failed: %v", err) + } +} + func runIssueShortcut(t *testing.T, server *httptest.Server, name string, args map[string]string) error { t.Helper() shortcut := findIssueShortcut(t, name) diff --git a/skills/gitlink-issue/SKILL.md b/skills/gitlink-issue/SKILL.md index 9d910d8..0928362 100644 --- a/skills/gitlink-issue/SKILL.md +++ b/skills/gitlink-issue/SKILL.md @@ -28,6 +28,7 @@ metadata: | `issue +batch-close` | 批量关闭 Issue,支持 `--dry-run` 预览 | 是(dry-run 不写入) | | `issue +comment` | 添加评论 | 是 | | `issue +assigners` | 查询 Issue 负责人列表 | 否(公开项目) | +| `issue +authors` | 查询 Issue 发布人列表 | 否(公开项目) | ## 使用示例 @@ -58,6 +59,9 @@ gitlink-cli issue +comment --number 4 --body "已修复,请验证" # 查询 Issue 负责人 gitlink-cli issue +assigners --owner Gitlink --repo forgeplus --keyword alice + +# 查询 Issue 发布人 +gitlink-cli issue +authors --owner Gitlink --repo forgeplus --keyword bob ``` ## Raw API 补充 diff --git a/skills/gitlink-issue/references/gitlink-issue-authors.md b/skills/gitlink-issue/references/gitlink-issue-authors.md new file mode 100644 index 0000000..49edc9f --- /dev/null +++ b/skills/gitlink-issue/references/gitlink-issue-authors.md @@ -0,0 +1,25 @@ +# Issue Authors + +Use `issue +authors` to list users who have authored Issues in a repository. +This helps users find author IDs for Issue filtering and reporting workflows. + +## Usage + +```bash +gitlink-cli issue +authors --owner Gitlink --repo forgeplus +gitlink-cli issue +authors --owner Gitlink --repo forgeplus --keyword bob +``` + +## Options + +| Option | Description | +|--------|-------------| +| `--owner` | Repository owner | +| `--repo` | Repository name | +| `--keyword`, `-k` | Optional search keyword | + +## API + +```http +GET /api/v1/{owner}/{repo}/issue_authors.json +```