gitlab-address-comments
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMR Comment Handler
MR评论处理指南
Find the open MR for the current branch and address its review threads using . Run all commands with elevated network access.
glabglab借助查找当前分支对应的开放MR并处理其评审线程。所有命令需使用提升的网络权限运行。
glabglabPrerequisites
前提条件
- Ensure succeeds (via
glab auth statusorglab auth login).GITLAB_TOKEN - Ensure is at least v1.80.4.
glab - When sandboxing blocks network calls, rerun with .
sandbox_permissions=require_escalated - Sanity check auth up front:
bash
glab auth status- 确保执行成功(可通过
glab auth status或配置glab auth login实现)。GITLAB_TOKEN - 确保版本至少为v1.80.4。
glab - 当沙箱环境阻止网络调用时,需添加参数重新运行。
sandbox_permissions=require_escalated - 预先进行身份验证合理性检查:
bash
glab auth status1) Resolve the MR for the current branch
1) 定位当前分支对应的MR
Do a quick check so we know which MR we are about to operate on:
bash
branch="$(git rev-parse --abbrev-ref HEAD)"
glab mr view "$branch" --output jsonIf this fails, the fetch script below will still try to locate the MR by .
source_branch先快速检查,明确我们要操作的MR:
bash
branch="$(git rev-parse --abbrev-ref HEAD)"
glab mr view "$branch" --output json如果此命令失败,下方的获取脚本会尝试通过定位MR。
source_branch2) Fetch unresolved discussions to /tmp
/tmp2) 将未解决的讨论内容获取到/tmp
目录
/tmpUse the local script to fetch MR discussions via . This filters out bot/system-only threads and returns unresolved discussions when is set.
glab api--open-commentsbash
skill_dir="<path-to-skill>"
branch="$(git rev-parse --abbrev-ref HEAD)"
safe_branch="${branch//\//_}"
out="/tmp/${safe_branch}_mr_open_discussions.json"
python "$skill_dir/scripts/fetch_comments.py" --open-comments --output "$out"If you want the full payload (including resolved discussions), drop .
--open-comments使用本地脚本通过获取MR讨论内容。添加参数时,会过滤掉机器人/系统专属线程,仅返回未解决的讨论。
glab api--open-commentsbash
skill_dir="<path-to-skill>"
branch="$(git rev-parse --abbrev-ref HEAD)"
safe_branch="${branch//\//_}"
out="/tmp/${safe_branch}_mr_open_discussions.json"
python "$skill_dir/scripts/fetch_comments.py" --open-comments --output "$out"如果需要完整的返回内容(包括已解决的讨论),请移除参数。
--open-comments3) Summarize, triage, and ask once
3) 总结、分类并一次性确认
- Load the JSON and number each unresolved discussion.
- Start with a compact summary list instead of dumping full threads.
- Sort by: unresolved first (already filtered), then most recently updated.
- When possible, group or label by file path to reduce context switching.
- In the summary list, show: number, discussion id, author, file:line (if present), and a one-line summary.
- Ask for a batch selection in one shot. Accept: ,
1,3,5-7,all, ornone.top N - If the user does not choose, suggest a small default set (for example ) with a short rationale.
top 3 - Only after selection, show the full thread and code context for the selected numbers.
- When showing code context, include 3 lines before and after and clearly mark the referenced line(s).
- 加载JSON文件,为每个未解决的讨论编号。
- 先展示简洁的总结列表,而非完整的线程内容。
- 排序规则:优先显示未解决的讨论(已过滤),其次按最近更新时间排序。
- 尽可能按文件路径分组或标记,减少上下文切换。
- 在总结列表中展示:编号、讨论ID、作者、文件:行号(若存在)以及一行摘要。
- 一次性请求用户批量选择,支持的格式:、
1,3,5-7、all或none。top N - 若用户未做出选择,建议一个小型默认集合(例如)并附上简短理由。
top 3 - 仅在用户选择后,才展示所选编号对应的完整线程及代码上下文。
- 展示代码上下文时,需包含引用行前后各3行内容,并清晰标记引用行。
4) Implement fixes for the selected discussions
4) 针对选中的讨论内容实施修复
- Apply focused fixes that address the selected threads.
- Run the most relevant tests or checks you can in-repo.
- Report back with: what changed, which discussion numbers were addressed, and any follow-ups.
Notes:
- If hits auth or rate issues, prompt the user to run
glabor re-exportglab auth login, then retry.GITLAB_TOKEN - If no open MR is found for the branch, say so clearly and ask for the MR URL or IID.
- Do not prompt “address or skip?” one comment at a time unless the user explicitly asks for that mode.
- 针对选中的线程进行精准修复。
- 在仓库内运行最相关的测试或检查。
- 反馈内容包括:修改内容、已处理的讨论编号以及后续待办事项。
注意事项:
- 若遇到身份验证或调用频率限制问题,提示用户运行
glab或重新导出glab auth login,然后重试。GITLAB_TOKEN - 若未找到当前分支对应的开放MR,需明确告知用户,并请求提供MR的URL或IID。
- 除非用户明确要求,否则不要逐个评论询问“处理还是跳过?”。