feat(issue): add batch maintenance shortcuts #165

Merged
wbtiger merged 1 commits from wangyue111/gitlink-cli:feat/issue-batch-maintenance into master 2026-06-16 00:15:18 +08:00
Contributor

背景

当前 gitlink-cli 已经有 issue +batch-close,可以批量关闭 Issue,但 GitLink OpenAPI 里还提供了更通用的 Issue 批量维护能力:

  • 批量更新 Issue 状态、优先级、里程碑、标签、负责人
  • 批量删除 Issue

这些能力适合仓库维护者做 Sprint 收尾、Issue 迁移、批量标记、批量分派等操作。为了降低批量写操作风险,本 PR 将 OpenAPI 封装成两个带安全约束的 Shortcut。

新增命令

gitlink-cli issue +batch-update
gitlink-cli issue +batch-delete

批量更新 Issue 元数据

gitlink-cli issue +batch-update \
  --owner Gitlink \
  --repo forgeplus \
  --ids 101,102 \
  --status-id 3 \
  --priority-id 2 \
  --tag-ids 7,8 \
  --assigner-ids 11,12 \
  --dry-run

批量删除 Issue

gitlink-cli issue +batch-delete \
  --owner Gitlink \
  --repo forgeplus \
  --ids 101,102 \
  --dry-run

# 真实删除必须显式确认
gitlink-cli issue +batch-delete \
  --owner Gitlink \
  --repo forgeplus \
  --ids 101,102 \
  --yes

OpenAPI 对齐

Command Method Endpoint
issue +batch-update PATCH /api/v1/{owner}/{repo}/issues/batch_update.json
issue +batch-delete DELETE /api/v1/{owner}/{repo}/issues/batch_destroy.json

ID 语义说明

这里特意区分两种 ID:

  • issue +batch-close --numbers 使用网页 URL 中的 Issue 编号,也就是 project_issues_index
  • issue +batch-update --idsissue +batch-delete --ids 使用 OpenAPI 返回的 API Issue ID

README、Skill 和命令 help 都明确说明 --ids 不是网页 Issue 编号,避免误用。

安全设计

  • batch-updatebatch-delete 都支持 --dry-run
  • batch-update 至少需要一个更新字段,否则直接报错
  • batch-delete 是破坏性操作,真实执行必须传 --yes
  • ID 列表只接受正整数,并自动去重
  • dry-run 输出 methodpathbody,方便用户和 Agent 先确认

交付内容

  • 功能代码:shortcuts/issue/batch.go
  • 单元测试:shortcuts/issue/batch_test.go
  • Shortcut 注册:shortcuts/issue/issue.go
  • README / README.zh-CN 命令示例
  • Skill 文档:skills/gitlink-issue/SKILL.md
  • Skill 总览:skills/README.md
  • 变更说明:doc/changes/issue-batch-maintenance.md

测试

git diff --check
GOPROXY=https://goproxy.cn,direct go test ./...
go vet ./...
go run . issue +batch-update --help
go run . issue +batch-delete --help
go run . issue +batch-update --owner wangyue111 --repo gitlink-cli --ids 101,102 --status-id 3 --dry-run --format json
go run . issue +batch-delete --owner wangyue111 --repo gitlink-cli --ids 101,102 --dry-run --format json

价值

这个 PR 补齐的是 Issue 批量维护闭环,而不是单个接口搬运。它和已合入的 issue +batch-close 形成互补:关闭使用网页 Issue 编号,批量更新/删除使用 OpenAPI Issue ID,并通过 dry-run / --yes 保护批量写操作安全。对仓库维护者、开源社区运营和 Agent 自动化维护都有实际价值。

## 背景 当前 gitlink-cli 已经有 `issue +batch-close`,可以批量关闭 Issue,但 GitLink OpenAPI 里还提供了更通用的 Issue 批量维护能力: - 批量更新 Issue 状态、优先级、里程碑、标签、负责人 - 批量删除 Issue 这些能力适合仓库维护者做 Sprint 收尾、Issue 迁移、批量标记、批量分派等操作。为了降低批量写操作风险,本 PR 将 OpenAPI 封装成两个带安全约束的 Shortcut。 ## 新增命令 ```bash gitlink-cli issue +batch-update gitlink-cli issue +batch-delete ``` ### 批量更新 Issue 元数据 ```bash gitlink-cli issue +batch-update \ --owner Gitlink \ --repo forgeplus \ --ids 101,102 \ --status-id 3 \ --priority-id 2 \ --tag-ids 7,8 \ --assigner-ids 11,12 \ --dry-run ``` ### 批量删除 Issue ```bash gitlink-cli issue +batch-delete \ --owner Gitlink \ --repo forgeplus \ --ids 101,102 \ --dry-run # 真实删除必须显式确认 gitlink-cli issue +batch-delete \ --owner Gitlink \ --repo forgeplus \ --ids 101,102 \ --yes ``` ## OpenAPI 对齐 | Command | Method | Endpoint | |---|---|---| | `issue +batch-update` | PATCH | `/api/v1/{owner}/{repo}/issues/batch_update.json` | | `issue +batch-delete` | DELETE | `/api/v1/{owner}/{repo}/issues/batch_destroy.json` | ## ID 语义说明 这里特意区分两种 ID: - `issue +batch-close --numbers` 使用网页 URL 中的 Issue 编号,也就是 `project_issues_index` - `issue +batch-update --ids` 和 `issue +batch-delete --ids` 使用 OpenAPI 返回的 API Issue ID README、Skill 和命令 help 都明确说明 `--ids` 不是网页 Issue 编号,避免误用。 ## 安全设计 - `batch-update` 和 `batch-delete` 都支持 `--dry-run` - `batch-update` 至少需要一个更新字段,否则直接报错 - `batch-delete` 是破坏性操作,真实执行必须传 `--yes` - ID 列表只接受正整数,并自动去重 - dry-run 输出 `method`、`path`、`body`,方便用户和 Agent 先确认 ## 交付内容 - 功能代码:`shortcuts/issue/batch.go` - 单元测试:`shortcuts/issue/batch_test.go` - Shortcut 注册:`shortcuts/issue/issue.go` - README / README.zh-CN 命令示例 - Skill 文档:`skills/gitlink-issue/SKILL.md` - Skill 总览:`skills/README.md` - 变更说明:`doc/changes/issue-batch-maintenance.md` ## 测试 ```bash git diff --check GOPROXY=https://goproxy.cn,direct go test ./... go vet ./... go run . issue +batch-update --help go run . issue +batch-delete --help go run . issue +batch-update --owner wangyue111 --repo gitlink-cli --ids 101,102 --status-id 3 --dry-run --format json go run . issue +batch-delete --owner wangyue111 --repo gitlink-cli --ids 101,102 --dry-run --format json ``` ## 价值 这个 PR 补齐的是 Issue 批量维护闭环,而不是单个接口搬运。它和已合入的 `issue +batch-close` 形成互补:关闭使用网页 Issue 编号,批量更新/删除使用 OpenAPI Issue ID,并通过 dry-run / --yes 保护批量写操作安全。对仓库维护者、开源社区运营和 Agent 自动化维护都有实际价值。
wangyue111 added 1 commit 2026-06-09 21:49:28 +08:00
wangyue111 force-pushed feat/issue-batch-maintenance from 965495734c to 0703d3eba9 2026-06-15 08:20:45 +08:00 Compare
wbtiger merged commit 982f2cb336 into master 2026-06-16 00:15:18 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Gitlink/gitlink-cli#165
No description provided.