check-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCheck PR
检查PR
Analyze a pull request for review comments, status checks, and description completeness, then help address any issues found.
分析拉取请求(PR)的评审评论、状态检查和描述完整性,随后协助解决发现的所有问题。
Inputs
输入项
- PR number (optional): If not provided, detect the PR for the current branch.
- PR编号(可选):如果未提供,则自动检测当前分支对应的PR。
Instructions
操作步骤
1. Identify the PR
1. 确定PR
If a PR number was provided, use it. Otherwise, detect it:
bash
gh pr view --json number -q .number如果提供了PR编号,则使用该编号。否则,自动检测:
bash
gh pr view --json number -q .number2. Fetch PR details
2. 获取PR详情
bash
gh pr view <PR_NUMBER> --json title,body,state,reviews,comments,headRefName,statusCheckRollup
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/commentsbash
gh pr view <PR_NUMBER> --json title,body,state,reviews,comments,headRefName,statusCheckRollup
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments3. Wait for pending checks
3. 等待待处理检查完成
Before analyzing, ensure all status checks have completed. If any checks are or , poll every 30 seconds until all checks reach a terminal state (success or failure). This ensures that review bot comments (Greptile, linters, etc.) are available before analysis.
PENDINGIN_PROGRESS在分析之前,确保所有状态检查已完成。如果存在任何处于(待处理)或(进行中)状态的检查,每30秒轮询一次,直到所有检查进入终端状态(成功或失败)。这可以确保分析前能获取到评审机器人(如Greptile、代码检查工具等)的评论。
PENDINGIN_PROGRESS4. Analyze the PR
4. 分析PR
Once all checks are complete, evaluate these areas:
所有检查完成后,对以下方面进行评估:
A. Status Checks
A. 状态检查
- Are all CI checks passing?
- If any are failing, identify which ones and the failure reason.
- 所有CI检查是否都已通过?
- 如果有检查失败,确定是哪些检查以及失败原因。
B. PR Description
B. PR描述
- Is the description complete and follows team conventions?
- Are all required sections filled in?
- Are there TODOs or placeholders that need updating?
- 描述是否完整且符合团队规范?
- 所有必填部分是否已填写?
- 是否存在需要更新的TODO项或占位符?
C. Review Comments
C. 评审评论
- Inline code review comments that need addressing
- Look for bot review comments (e.g. from , linters, etc.)
greptile-apps[bot] - Human reviewer comments
- 需要处理的内联代码评审评论
- 查找机器人评审评论(如来自、代码检查工具等的评论)
greptile-apps[bot] - 人工评审者的评论
D. General Comments
D. 通用评论
- Discussion comments on the PR
- Bot comments (Vercel deploy previews, etc.) — usually informational
- PR上的讨论类评论
- 机器人评论(如Vercel部署预览等)——通常为信息类评论
5. Categorize issues
5. 分类问题
For each issue found, categorize as:
| Category | Meaning |
|---|---|
| Actionable | Code changes, test improvements, or fixes needed |
| Informational | Verification notes, questions, or FYIs that don't require changes |
| Already addressed | Issues that appear to be resolved by subsequent commits |
对发现的每个问题进行分类:
| 分类 | 含义 |
|---|---|
| 可操作类 | 需要修改代码、改进测试或进行修复 |
| 信息类 | 验证说明、疑问或仅供参考的内容,无需修改 |
| 已处理 | 后续提交似乎已解决的问题 |
6. Report findings
6. 汇报结果
Present a summary table:
| Area | Issue | Status | Action Needed |
|---|---|---|---|
| Status Checks | CI build failing | Failing | Fix type error in |
| Review | "Add null check" — @reviewer | Actionable | Add guard clause |
| Description | TODO placeholder in test plan | Actionable | Fill in test plan |
| Review | "Looks good" — @teammate | Informational | None |
呈现汇总表格:
| 领域 | 问题 | 状态 | 所需操作 |
|---|---|---|---|
| 状态检查 | CI构建失败 | 失败 | 修复 |
| 评审 | "添加空值检查" — @评审者 | 可操作 | 添加保护子句 |
| 描述 | 测试计划中存在TODO占位符 | 可操作 | 完善测试计划 |
| 评审 | "看起来不错" — @团队成员 | 信息类 | 无 |
7. Fix issues (if requested)
7. 修复问题(若有需求)
If there are actionable items:
- Switch to the PR's branch if not already on it.
- Ask the user if they want to fix the issues.
- If yes, make the fixes, commit, and push.
如果存在可操作项:
- 若当前未处于PR分支,则切换到该分支。
- 询问用户是否需要修复这些问题。
- 如果用户同意,进行修复、提交并推送代码。
8. Resolve review threads
8. 解决评审线程
After addressing comments, resolve the corresponding review threads.
First, fetch unresolved thread IDs (paginate if needed — see the GraphQL reference):
bash
gh api graphql -f query='
query($cursor: String) {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100, after: $cursor) {
pageInfo { hasNextPage endCursor }
nodes {
id
isResolved
comments(first: 1) {
nodes { body path }
}
}
}
}
}
}'If is true, repeat with to get remaining threads.
hasNextPage-f cursor=ENDCURSORThen resolve threads that have been addressed or are informational:
bash
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID"}) {
thread { isResolved }
}
}'Batch multiple resolutions into a single mutation using aliases (, , etc.).
t1t2处理完评论后,解决对应的评审线程。
首先,获取未解决的线程ID(若需要则分页——参考GraphQL参考文档):
bash
gh api graphql -f query='
query($cursor: String) {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100, after: $cursor) {
pageInfo { hasNextPage endCursor }
nodes {
id
isResolved
comments(first: 1) {
nodes { body path }
}
}
}
}
}
}'如果为true,使用重复执行以获取剩余线程。
hasNextPage-f cursor=ENDCURSOR然后,解决已处理或属于信息类的线程:
bash
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID"}) {
thread { isResolved }
}
}'使用别名(、等)将多个解决操作批量处理为单个mutation。
t1t29. Multiple PRs
9. 多个PR
If checking a chain of PRs, process them sequentially.
如果需要检查一系列PR,按顺序处理它们。
Output format
输出格式
Summarize:
- PR title and current state
- Status checks summary (passing/failing/pending)
- Total issues found
- Actionable items with descriptions
- Items that can be ignored with reasons
- Recommended next steps
汇总内容包括:
- PR标题和当前状态
- 状态检查汇总(通过/失败/待处理)
- 发现的问题总数
- 可操作项及描述
- 可忽略项及原因
- 建议的下一步操作