feat(issue): add assigners shortcut
This commit is contained in:
parent
a46e06b78a
commit
9638d279d3
|
|
@ -198,6 +198,9 @@ gitlink-cli issue +batch-close --owner Gitlink --repo forgeplus --from issues.cs
|
||||||
|
|
||||||
# Add a comment
|
# Add a comment
|
||||||
gitlink-cli issue +comment --owner Gitlink --repo forgeplus -i 123 -b "Fixed"
|
gitlink-cli issue +comment --owner Gitlink --repo forgeplus -i 123 -b "Fixed"
|
||||||
|
|
||||||
|
# List issue assigners
|
||||||
|
gitlink-cli issue +assigners --owner Gitlink --repo forgeplus
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,9 @@ gitlink-cli issue +batch-close --owner Gitlink --repo forgeplus --from issues.cs
|
||||||
|
|
||||||
# 添加评论
|
# 添加评论
|
||||||
gitlink-cli issue +comment --owner Gitlink --repo forgeplus -i 123 -b "已修复"
|
gitlink-cli issue +comment --owner Gitlink --repo forgeplus -i 123 -b "已修复"
|
||||||
|
|
||||||
|
# 列出 Issue 负责人
|
||||||
|
gitlink-cli issue +assigners --owner Gitlink --repo forgeplus
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pull Request
|
### Pull Request
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,27 @@ func Shortcuts() []*common.Shortcut {
|
||||||
return ctx.Output(env)
|
return ctx.Output(env)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "assigners",
|
||||||
|
Description: "List issue assigners",
|
||||||
|
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_assigners", q)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return ctx.Output(env)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,29 @@ func TestBatchClosePreservesCurrentDescription(t *testing.T) {
|
||||||
assertEqual(t, updatePayload["status_id"], float64(5))
|
assertEqual(t, updatePayload["status_id"], float64(5))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssueAssignersShortcutWithKeyword(t *testing.T) {
|
||||||
|
server := newIssueTestServer(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method != "GET" || r.URL.Path != "/v1/owner/repo/issue_assigners.json" {
|
||||||
|
t.Fatalf("unexpected request: %s %s", r.Method, r.URL.Path)
|
||||||
|
}
|
||||||
|
assertEqual(t, r.URL.Query().Get("keyword"), "alice")
|
||||||
|
writeJSON(t, w, map[string]interface{}{
|
||||||
|
"total_count": 1,
|
||||||
|
"assigners": []map[string]interface{}{
|
||||||
|
{"id": 7, "name": "Alice", "login": "alice"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
defer server.Close()
|
||||||
|
|
||||||
|
err := runIssueShortcut(t, server, "assigners", map[string]string{
|
||||||
|
"keyword": "alice",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("assigners shortcut failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func runIssueShortcut(t *testing.T, server *httptest.Server, name string, args map[string]string) error {
|
func runIssueShortcut(t *testing.T, server *httptest.Server, name string, args map[string]string) error {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
shortcut := findIssueShortcut(t, name)
|
shortcut := findIssueShortcut(t, name)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ metadata:
|
||||||
| `issue +close` | 关闭 Issue | 是 |
|
| `issue +close` | 关闭 Issue | 是 |
|
||||||
| `issue +batch-close` | 批量关闭 Issue,支持 `--dry-run` 预览 | 是(dry-run 不写入) |
|
| `issue +batch-close` | 批量关闭 Issue,支持 `--dry-run` 预览 | 是(dry-run 不写入) |
|
||||||
| `issue +comment` | 添加评论 | 是 |
|
| `issue +comment` | 添加评论 | 是 |
|
||||||
|
| `issue +assigners` | 查询 Issue 负责人列表 | 否(公开项目) |
|
||||||
|
|
||||||
## 使用示例
|
## 使用示例
|
||||||
|
|
||||||
|
|
@ -54,6 +55,9 @@ gitlink-cli issue +batch-close --owner myuser --repo myrepo --from issues.csv
|
||||||
|
|
||||||
# 添加评论
|
# 添加评论
|
||||||
gitlink-cli issue +comment --number 4 --body "已修复,请验证"
|
gitlink-cli issue +comment --number 4 --body "已修复,请验证"
|
||||||
|
|
||||||
|
# 查询 Issue 负责人
|
||||||
|
gitlink-cli issue +assigners --owner Gitlink --repo forgeplus --keyword alice
|
||||||
```
|
```
|
||||||
|
|
||||||
## Raw API 补充
|
## Raw API 补充
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Issue Assigners
|
||||||
|
|
||||||
|
Use `issue +assigners` to list users that can be assigned to Issues in a repository.
|
||||||
|
This helps users find the assignee ID before creating or updating an Issue.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gitlink-cli issue +assigners --owner Gitlink --repo forgeplus
|
||||||
|
gitlink-cli issue +assigners --owner Gitlink --repo forgeplus --keyword alice
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
| Option | Description |
|
||||||
|
|--------|-------------|
|
||||||
|
| `--owner` | Repository owner |
|
||||||
|
| `--repo` | Repository name |
|
||||||
|
| `--keyword`, `-k` | Optional search keyword |
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```http
|
||||||
|
GET /api/v1/{owner}/{repo}/issue_assigners.json
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue