feat(issue): add batch comment shortcut with dry-run support #14

Closed
wangyue111 wants to merge 1 commits from wangyue111/gitlink-cli:feat/issue-batch-comment into master
Contributor

背景

PR #12 已新增 issue +batch-close,解决了仓库维护者批量关闭过期/重复/已完成 Issue 的需求。但真实社区治理里,直接关闭 Issue 往往过于生硬,维护者通常需要先批量留言提醒、补充说明或请求确认,再根据反馈决定是否关闭。

本 PR 在 Issue 批量维护链路中新增一个更安全的前置动作:issue +batch-comment

新增功能

新增 gitlink-cli issue +batch-comment

  • 支持 --numbers 1,2,3,语义与 v1 API 保持一致,传入网页 URL 中的 Issue 编号(project_issues_index),不是数据库 ID
  • 支持 --from issues.csv 从 CSV 读取 Issue 编号
  • 支持 --body/-b 指定批量评论内容
  • 支持 --dry-run 预览,不修改线上数据
  • 输出批量操作结果汇总,包括 total/succeeded/failed/results
  • 复用已有批量 Issue 编号解析逻辑,与 issue +batch-close 保持一致

API

每个 Issue 使用已有 v1 评论接口:

POST /v1/{owner}/{repo}/issues/{number}/journals
Body: { "notes": <comment body> }

示例

# 预览,不写入线上数据
gitlink-cli issue +batch-comment --owner Gitlink --repo forgeplus --numbers 1,2,3 --body "请确认该 Issue 是否仍需处理。" --dry-run

# 对多个 Issue 批量添加评论
gitlink-cli issue +batch-comment --owner Gitlink --repo forgeplus --numbers 1,2,3 --body "该 Issue 长期无更新,如仍需处理请回复。"

# 从 CSV 文件读取 Issue 编号
gitlink-cli issue +batch-comment --owner Gitlink --repo forgeplus --from issues.csv --body "该 Issue 长期无更新,如仍需处理请回复。"

测试

已完成本地验证:

GOPROXY=https://goproxy.cn,direct go test ./...
go vet ./...
go run . issue +batch-comment --help
go run . issue +batch-comment --owner wangyue111 --repo gitlink-cli --numbers 6 --body "..." --dry-run --format json
go run . issue +batch-comment --owner wangyue111 --repo gitlink-cli --numbers 6 --body "..." --format json

真实仓库验证:在 fork 仓库 wangyue111/gitlink-cli 创建测试 Issue #6,dry-run 和真实批量评论均成功,comment_journals_count 从 0 变为 1;验证结束后已关闭测试 Issue,描述仍保留。

文档

  • 更新 README.md / README.zh-CN.md
  • 更新 skills/README.md
  • 更新 skills/gitlink-issue/SKILL.md
  • 新增 skills/gitlink-issue/references/gitlink-issue-batch-comment.md

与 PR #12/#13 的关系

  • PR #12 已合并:提供 issue +batch-close
  • 本 PR 提供 issue +batch-comment,作为批量关闭前的沟通和提醒能力
  • PR #13 的 Agent 安全批量维护工作流可以后续扩展为:先 dry-run 批量评论 → 用户确认 → 执行评论 → 再按条件批量关闭
## 背景 PR #12 已新增 `issue +batch-close`,解决了仓库维护者批量关闭过期/重复/已完成 Issue 的需求。但真实社区治理里,直接关闭 Issue 往往过于生硬,维护者通常需要先批量留言提醒、补充说明或请求确认,再根据反馈决定是否关闭。 本 PR 在 Issue 批量维护链路中新增一个更安全的前置动作:`issue +batch-comment`。 ## 新增功能 新增 `gitlink-cli issue +batch-comment`: - 支持 `--numbers 1,2,3`,语义与 v1 API 保持一致,传入网页 URL 中的 Issue 编号(`project_issues_index`),不是数据库 ID - 支持 `--from issues.csv` 从 CSV 读取 Issue 编号 - 支持 `--body/-b` 指定批量评论内容 - 支持 `--dry-run` 预览,不修改线上数据 - 输出批量操作结果汇总,包括 `total/succeeded/failed/results` - 复用已有批量 Issue 编号解析逻辑,与 `issue +batch-close` 保持一致 ## API 每个 Issue 使用已有 v1 评论接口: ```text POST /v1/{owner}/{repo}/issues/{number}/journals Body: { "notes": <comment body> } ``` ## 示例 ```bash # 预览,不写入线上数据 gitlink-cli issue +batch-comment --owner Gitlink --repo forgeplus --numbers 1,2,3 --body "请确认该 Issue 是否仍需处理。" --dry-run # 对多个 Issue 批量添加评论 gitlink-cli issue +batch-comment --owner Gitlink --repo forgeplus --numbers 1,2,3 --body "该 Issue 长期无更新,如仍需处理请回复。" # 从 CSV 文件读取 Issue 编号 gitlink-cli issue +batch-comment --owner Gitlink --repo forgeplus --from issues.csv --body "该 Issue 长期无更新,如仍需处理请回复。" ``` ## 测试 已完成本地验证: ```bash GOPROXY=https://goproxy.cn,direct go test ./... go vet ./... go run . issue +batch-comment --help go run . issue +batch-comment --owner wangyue111 --repo gitlink-cli --numbers 6 --body "..." --dry-run --format json go run . issue +batch-comment --owner wangyue111 --repo gitlink-cli --numbers 6 --body "..." --format json ``` 真实仓库验证:在 fork 仓库 `wangyue111/gitlink-cli` 创建测试 Issue `#6`,dry-run 和真实批量评论均成功,`comment_journals_count` 从 0 变为 1;验证结束后已关闭测试 Issue,描述仍保留。 ## 文档 - 更新 `README.md` / `README.zh-CN.md` - 更新 `skills/README.md` - 更新 `skills/gitlink-issue/SKILL.md` - 新增 `skills/gitlink-issue/references/gitlink-issue-batch-comment.md` ## 与 PR #12/#13 的关系 - PR #12 已合并:提供 `issue +batch-close` - 本 PR 提供 `issue +batch-comment`,作为批量关闭前的沟通和提醒能力 - PR #13 的 Agent 安全批量维护工作流可以后续扩展为:先 dry-run 批量评论 → 用户确认 → 执行评论 → 再按条件批量关闭
wangyue111 added 1 commit 2026-05-13 22:19:30 +08:00
wbtiger closed this pull request 2026-05-14 14:44:42 +08:00

Pull request closed

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#14
No description provided.