github-pr-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub PR Workflow
GitHub PR 工作流程
Key Concepts
核心概念
Comment Types
评论类型
GitHub PRs have two different types of comments:
- PR-level comments - General discussion on the PR (shown via )
gh pr view --comments - Inline code review comments - Comments attached to specific lines of code (requires API)
Important: does NOT show inline code review comments!
gh pr view --commentsGitHub PR 包含两种不同类型的评论:
- PR-level comments - 针对PR的一般性讨论(可通过查看)
gh pr view --comments - Inline code review comments - 附加到特定代码行的评论(需要调用API)
重要提示: 不会显示行内代码评审评论!
gh pr view --commentsScripts
脚本
| Script | Purpose |
|---|---|
| Comprehensive PR info: summary, CI checks and unresolved review and inline comments |
The script auto-detects the repo from git remote, or accepts as second argument (format: ).
[REPO]owner/repoKey features:
- Uses GitHub's GraphQL API to reliably filter out already resolved/addressed comments
- Excludes collapsed/hidden review threads
- Excludes minimized comments (marked as spam/off-topic/resolved)
- Excludes dismissed reviews
- Shows only what still needs attention
| 脚本 | 用途 |
|---|---|
| 全面的PR信息:摘要、CI检查结果以及未解决的评审和行内评论 |
该脚本会从Git远程仓库自动检测repo,也可接受作为第二个参数(格式:)。
[REPO]owner/repo核心特性:
- 使用GitHub的GraphQL API可靠过滤已解决/处理的评论
- 排除折叠/隐藏的评审线程
- 排除已最小化的评论(标记为垃圾信息/偏离主题/已解决)
- 排除已驳回的评审
- 仅显示仍需关注的内容
Common Commands
常用命令
bash
undefinedbash
undefinedGet complete PR info with UNRESOLVED comments only
获取仅包含未解决评论的完整PR信息
gh-pr-info <PR> [REPO] # ✅ Everything you need: summary, checks, reviews, unresolved comments
gh-pr-info <PR> [REPO] # ✅ 所需信息一应俱全:摘要、检查结果、评审、未解决评论
Basic PR info (native gh commands)
基础PR信息(原生gh命令)
gh pr view <PR> # Overview
gh pr view <PR> --comments # PR-level comments only (NOT inline!)
gh pr diff <PR> # View the diff
gh pr view <PR> # 概览
gh pr view <PR> --comments # 仅显示PR-level comments(不包含行内评论!)
gh pr diff <PR> # 查看差异
Reviews (approve/request changes)
评审(批准/请求修改)
gh pr review <PR> --approve
gh pr review <PR> --request-changes --body "Please fix X"
gh pr review <PR> --comment --body "Looks good overall"
gh pr review <PR> --approve
gh pr review <PR> --request-changes --body "请修复X问题"
gh pr review <PR> --comment --body "整体看起来不错"
Checks
检查
gh pr checks <PR> # CI status
gh run view <RUN_ID> --log-failed # Failed job logs
undefinedgh pr checks <PR> # CI状态
gh run view <RUN_ID> --log-failed # 失败任务日志
undefinedAPI Endpoints Reference
API 端点参考
When commands don't expose what you need, use the API:
ghbash
undefined当命令无法提供你需要的信息时,可以使用API:
ghbash
undefinedInline review comments
行内评审评论
gh api repos/OWNER/REPO/pulls/PR/comments
gh api repos/OWNER/REPO/pulls/PR/comments
PR-level comments (issue comments)
PR级评论(议题评论)
gh api repos/OWNER/REPO/issues/PR/comments
gh api repos/OWNER/REPO/issues/PR/comments
Review submissions
评审提交记录
gh api repos/OWNER/REPO/pulls/PR/reviews
gh api repos/OWNER/REPO/pulls/PR/reviews
Commits in PR
PR中的提交
gh api repos/OWNER/REPO/pulls/PR/commits
gh api repos/OWNER/REPO/pulls/PR/commits
Files changed
已修改文件
gh api repos/OWNER/REPO/pulls/PR/files
undefinedgh api repos/OWNER/REPO/pulls/PR/files
undefinedWorkflow: Addressing Review Comments
工作流程:处理评审评论
- Get unresolved comments:
gh-pr-info <PR> - Make fixes in your local branch
- 获取未解决的评论:
gh-pr-info <PR> - 在本地分支中进行修复