github-pr-workflow

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub PR Workflow

GitHub PR 工作流程

Key Concepts

核心概念

Comment Types

评论类型

GitHub PRs have two different types of comments:
  1. PR-level comments - General discussion on the PR (shown via
    gh pr view --comments
    )
  2. Inline code review comments - Comments attached to specific lines of code (requires API)
Important:
gh pr view --comments
does NOT show inline code review comments!
GitHub PR 包含两种不同类型的评论
  1. PR-level comments - 针对PR的一般性讨论(可通过
    gh pr view --comments
    查看)
  2. Inline code review comments - 附加到特定代码行的评论(需要调用API)
重要提示
gh pr view --comments
不会显示行内代码评审评论!

Scripts

脚本

ScriptPurpose
gh-pr-info <PR> [REPO]
Comprehensive PR info: summary, CI checks and unresolved review and inline comments
The script auto-detects the repo from git remote, or accepts
[REPO]
as second argument (format:
owner/repo
).
Key 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
脚本用途
gh-pr-info <PR> [REPO]
全面的PR信息:摘要、CI检查结果以及未解决的评审和行内评论
该脚本会从Git远程仓库自动检测repo,也可接受
[REPO]
作为第二个参数(格式:
owner/repo
)。
核心特性
  • 使用GitHub的GraphQL API可靠过滤已解决/处理的评论
  • 排除折叠/隐藏的评审线程
  • 排除已最小化的评论(标记为垃圾信息/偏离主题/已解决)
  • 排除已驳回的评审
  • 仅显示仍需关注的内容

Common Commands

常用命令

bash
undefined
bash
undefined

Get 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
undefined
gh pr checks <PR> # CI状态 gh run view <RUN_ID> --log-failed # 失败任务日志
undefined

API Endpoints Reference

API 端点参考

When
gh
commands don't expose what you need, use the API:
bash
undefined
gh
命令无法提供你需要的信息时,可以使用API:
bash
undefined

Inline 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
undefined
gh api repos/OWNER/REPO/pulls/PR/files
undefined

Workflow: Addressing Review Comments

工作流程:处理评审评论

  1. Get unresolved comments:
    gh-pr-info <PR>
  2. Make fixes in your local branch
  1. 获取未解决的评论
    gh-pr-info <PR>
  2. 在本地分支中进行修复