attach-review-to-pr

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

How to Attach Line-Specific Review Comments to Pull Requests

如何为拉取请求添加特定行的评审评论

This guide explains how to add line-specific review comments to pull requests using the GitHub CLI (
gh
) API or
mcp__github_inline_comment__create_inline_comment
if it not available, similar to how the GitHub UI allows commenting on specific lines of code.
本指南说明如何使用GitHub CLI(
gh
)API或
mcp__github_inline_comment__create_inline_comment
(当前者不可用时)为拉取请求添加特定行的评审评论,这与GitHub UI中针对代码特定行添加评论的方式类似。

Preferred Approach: Using MCP GitHub Tools

首选方法:使用MCP GitHub工具

If available, use the
mcp__github_inline_comment__create_inline_comment
MCP tool for posting line-specific inline comments on pull requests. This approach provides better integration with GitHub's UI and is the recommended method.
Fallback: If the MCP tool is not available, use the GitHub CLI (
gh
) API methods described below:
如果可用,请使用
mcp__github_inline_comment__create_inline_comment
MCP工具在拉取请求上发布特定行的内联评论。此方法与GitHub UI的集成度更高,是推荐的方式。
备选方案:如果MCP工具不可用,请使用以下GitHub CLI(
gh
)API方法:

Overview

概述

While
gh pr review
provides basic review functionality (approve, request changes, general comments), it does not support line-specific comments directly. To add comments on specific lines of code, you must use the lower-level
gh api
command to call GitHub's REST API directly.
虽然
gh pr review
提供了基础的评审功能(批准、请求修改、通用评论),但它不直接支持特定行评论。要在代码的特定行添加评论,必须使用更底层的
gh api
命令直接调用GitHub的REST API。

Prerequisites

前提条件

  1. GitHub CLI installed and authenticated:
    bash
    gh auth status
  2. Access to the repository and pull request you want to review
  1. 已安装并完成认证的GitHub CLI:
    bash
    gh auth status
  2. 拥有目标仓库和拉取请求的访问权限

Understanding GitHub's Review Comment System

理解GitHub的评审评论系统

GitHub has two types of PR comments:
  1. Issue Comments - General comments on the PR conversation
  2. Review Comments - Line-specific comments on code changes
Review comments can be added in two ways:
  • Single comment - Using the
    /pulls/{pr}/comments
    endpoint
  • Review with multiple comments - Using the
    /pulls/{pr}/reviews
    endpoint
GitHub有两种类型的PR评论:
  1. 议题评论 - 针对PR对话的通用评论
  2. 评审评论 - 针对代码变更的特定行评论
评审评论可以通过两种方式添加:
  • 单个评论 - 使用
    /pulls/{pr}/comments
    端点
  • 包含多个评论的评审 - 使用
    /pulls/{pr}/reviews
    端点

Adding a Single Line-Specific Comment

添加单个特定行评论

Basic Syntax

基本语法

bash
gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
  -f body='Your comment text here' \
  -f commit_id='<commit-sha>' \
  -f path='path/to/file.js' \
  -F line=42 \
  -f side='RIGHT'
bash
gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
  -f body='你的评论内容' \
  -f commit_id='<commit-sha>' \
  -f path='path/to/file.js' \
  -F line=42 \
  -f side='RIGHT'

Parameters Explained

参数说明

ParameterTypeRequiredDescription
body
stringYesThe text of the review comment (supports Markdown)
commit_id
stringYesThe SHA of the commit to comment on
path
stringYesRelative path to the file being commented on
line
integerYesThe line number in the diff (use
-F
for integers)
side
stringYes
RIGHT
for new/modified lines,
LEFT
for deleted lines
start_line
integerNoFor multi-line comments, the starting line
start_side
stringNoFor multi-line comments, the starting side
参数类型是否必填描述
body
string评审评论的文本内容(支持Markdown)
commit_id
string要评论的提交SHA值
path
string被评论文件的相对路径
line
integer差异中的行号(整数需使用
-F
参数)
side
string
RIGHT
代表新增/修改的行,
LEFT
代表删除的行
start_line
integer多行评论的起始行
start_side
string多行评论的起始侧

Parameter Flags

参数标志

  • -f
    (--field) - For string values
  • -F
    (--field) - For integer values (note the capital F)
  • -f
    (--field)- 用于字符串值
  • -F
    (--field)- 用于整数值(注意大写F)

Complete Example

完整示例

bash
undefined
bash
undefined

First, get the latest commit SHA for the PR

首先获取PR的最新提交SHA值

gh api repos/NeoLabHQ/learning-platform-app/pulls/4 --jq '.head.sha'
gh api repos/NeoLabHQ/learning-platform-app/pulls/4 --jq '.head.sha'

Then add your comment

然后添加评论

gh api repos/NeoLabHQ/learning-platform-app/pulls/4/comments
-f body='Consider adding error handling here. Should we confirm the lesson was successfully marked as completed before navigating away?'
-f commit_id='e152d0dd6cf498467eadbeb638bf05abe11c64d4'
-f path='src/components/LessonNavigationButtons.tsx'
-F line=26
-f side='RIGHT'
undefined
gh api repos/NeoLabHQ/learning-platform-app/pulls/4/comments
-f body='考虑在此处添加错误处理。我们是否应该在跳转前确认课程已成功标记为完成?'
-f commit_id='e152d0dd6cf498467eadbeb638bf05abe11c64d4'
-f path='src/components/LessonNavigationButtons.tsx'
-F line=26
-f side='RIGHT'
undefined

Understanding Line Numbers

理解行号

The
line
parameter refers to the position in the diff, not the absolute line number in the file:
  • For new files: Line numbers match the file's line numbers
  • For modified files: Use the line number as it appears in the "Files changed" tab
  • For multi-line comments: Use
    start_line
    and
    line
    to specify the range
line
参数指的是差异中的位置,而非文件中的绝对行号:
  • 新文件:行号与文件中的行号一致
  • 修改的文件:使用"文件变更"标签中显示的行号
  • 多行评论:使用
    start_line
    line
    指定范围

Response

响应

On success, returns a JSON object with comment details:
json
{
  "id": 2532291222,
  "pull_request_review_id": 3470545909,
  "path": "src/components/LessonNavigationButtons.tsx",
  "line": 26,
  "body": "Consider adding error handling here...",
  "html_url": "https://github.com/NeoLabHQ/learning-platform-app/pull/4#discussion_r2532291222",
  "created_at": "2025-11-16T22:40:46Z"
}
成功时,返回包含评论详情的JSON对象:
json
{
  "id": 2532291222,
  "pull_request_review_id": 3470545909,
  "path": "src/components/LessonNavigationButtons.tsx",
  "line": 26,
  "body": "Consider adding error handling here...",
  "html_url": "https://github.com/NeoLabHQ/learning-platform-app/pull/4#discussion_r2532291222",
  "created_at": "2025-11-16T22:40:46Z"
}

Adding Multiple Line-Specific Comments Together

批量添加多个特定行评论

To add multiple comments across different files in a single review, use the
/reviews
endpoint with JSON input.
要在一次评审中为不同文件添加多个评论,请使用
/reviews
端点并传入JSON输入。

Why Use Reviews for Multiple Comments?

为何使用评审端点添加多个评论?

  • Atomic operation - All comments are added together
  • Single notification - Doesn't spam with multiple notifications
  • Better UX - Appears as one cohesive review
  • Same mechanism as GitHub UI - "Start a review" → "Finish review"
  • 原子操作 - 所有评论同时添加
  • 单一通知 - 不会发送多条通知造成骚扰
  • 更好的用户体验 - 显示为一个连贯的评审
  • 与GitHub UI机制一致 - "开始评审" → "完成评审"

Basic Syntax

基本语法

bash
cat <<'EOF' | gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews --input -
{
  "event": "COMMENT",
  "body": "Overall review summary (optional)",
  "comments": [
    {
      "path": "file1.tsx",
      "body": "Comment on file 1",
      "side": "RIGHT",
      "line": 15
    },
    {
      "path": "file2.tsx",
      "body": "Comment on file 2",
      "side": "RIGHT",
      "line": 30
    }
  ]
}
EOF
bash
cat <<'EOF' | gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews --input -
{
  "event": "COMMENT",
  "body": "整体评审摘要(可选)",
  "comments": [
    {
      "path": "file1.tsx",
      "body": "针对文件1的评论",
      "side": "RIGHT",
      "line": 15
    },
    {
      "path": "file2.tsx",
      "body": "针对文件2的评论",
      "side": "RIGHT",
      "line": 30
    }
  ]
}
EOF

Review Event Types

评审事件类型

EventDescriptionWhen to Use
COMMENT
General review commentJust leaving feedback without approval
APPROVE
Approve the PRChanges look good, ready to merge
REQUEST_CHANGES
Request changesIssues that must be fixed before merge
事件描述使用场景
COMMENT
通用评审评论仅留下反馈,不进行批准
APPROVE
批准PR变更符合要求,可合并
REQUEST_CHANGES
请求修改存在必须修复的问题才能合并

Complete Example

完整示例

bash
cat <<'EOF' | gh api repos/NeoLabHQ/learning-platform-app/pulls/4/reviews --input -
{
  "event": "COMMENT",
  "body": "Testing multiple line-specific comments via gh api",
  "comments": [
    {
      "path": "src/components/CourseCard.tsx",
      "body": "Test comment generated by Claude",
      "side": "RIGHT",
      "line": 15
    },
    {
      "path": "src/components/CourseProgressWidget.tsx",
      "body": "Test comment generated by Claude",
      "side": "RIGHT",
      "line": 30
    },
    {
      "path": "src/components/LessonProgressTracker.tsx",
      "body": "Test comment generated by Claude",
      "side": "RIGHT",
      "line": 20
    }
  ]
}
EOF
bash
cat <<'EOF' | gh api repos/NeoLabHQ/learning-platform-app/pulls/4/reviews --input -
{
  "event": "COMMENT",
  "body": "通过gh api测试多个特定行评论",
  "comments": [
    {
      "path": "src/components/CourseCard.tsx",
      "body": "由Claude生成的测试评论",
      "side": "RIGHT",
      "line": 15
    },
    {
      "path": "src/components/CourseProgressWidget.tsx",
      "body": "由Claude生成的测试评论",
      "side": "RIGHT",
      "line": 30
    },
    {
      "path": "src/components/LessonProgressTracker.tsx",
      "body": "由Claude生成的测试评论",
      "side": "RIGHT",
      "line": 20
    }
  ]
}
EOF

Response

响应

json
{
  "id": 3470546747,
  "state": "COMMENTED",
  "html_url": "https://github.com/NeoLabHQ/learning-platform-app/pull/4#pullrequestreview-3470546747",
  "submitted_at": "2025-11-16T22:42:43Z",
  "commit_id": "e152d0dd6cf498467eadbeb638bf05abe11c64d4"
}
json
{
  "id": 3470546747,
  "state": "COMMENTED",
  "html_url": "https://github.com/NeoLabHQ/learning-platform-app/pull/4#pullrequestreview-3470546747",
  "submitted_at": "2025-11-16T22:42:43Z",
  "commit_id": "e152d0dd6cf498467eadbeb638bf05abe11c64d4"
}

Common Issues and Solutions

常见问题及解决方案

Issue 1: "user_id can only have one pending review per pull request"

问题1:"user_id can only have one pending review per pull request"

Error Message:
gh: Validation Failed (HTTP 422)
{"message":"Validation Failed","errors":[{"resource":"PullRequestReview","code":"custom","field":"user_id","message":"user_id can only have one pending review per pull request"}]}
Cause: GitHub only allows one pending (unsubmitted) review per user per PR. If you previously started a review through the UI or API and didn't submit it, it blocks new review creation.
Solution 1: Submit the pending review
bash
undefined
错误信息:
gh: Validation Failed (HTTP 422)
{"message":"Validation Failed","errors":[{"resource":"PullRequestReview","code":"custom","field":"user_id","message":"user_id can only have one pending review per pull request"}]}
原因: GitHub只允许每个用户针对每个PR存在一个待处理(未提交)的评审。如果您之前通过UI或API启动了评审但未提交,会阻止创建新的评审。
解决方案1:提交待处理的评审
bash
undefined

Check for pending reviews

检查待处理的评审

gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews | jq '.[] | select(.state=="PENDING")'
gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews | jq '.[] | select(.state=="PENDING")'

Submit it through the UI or ask the user to submit it

通过UI提交,或让用户自行提交


**Solution 2: Use the single comment endpoint instead**

```bash

**解决方案2:改用单个评论端点**

```bash

Add individual comments without creating a review

添加单个评论,无需创建评审

gh api repos/{owner}/{repo}/pulls/{pr_number}/comments
-f body='Comment text'
-f commit_id='<sha>'
-f path='file.tsx'
-F line=26
-f side='RIGHT'
undefined
gh api repos/{owner}/{repo}/pulls/{pr_number}/comments
-f body='评论内容'
-f commit_id='<sha>'
-f path='file.tsx'
-F line=26
-f side='RIGHT'
undefined

Issue 2: Array syntax not working with --raw-field

问题2:数组语法无法与--raw-field一起使用

Failed Attempt:
bash
undefined
失败尝试:
bash
undefined

This does NOT work - GitHub API receives an object, not an array

此方法无效 - GitHub API接收的是对象而非数组

gh api repos/{owner}/{repo}/pulls/{pr}/reviews
--raw-field 'comments[0][path]=file1.tsx'
--raw-field 'comments[0][line]=15'
--raw-field 'comments[1][path]=file2.tsx'
--raw-field 'comments[1][line]=30'

**Error:**
Invalid request. For 'properties/comments', {"0" => {...}, "1" => {...}} is not an array.

**Solution:** Use JSON input via heredoc:

```bash
cat <<'EOF' | gh api repos/{owner}/{repo}/pulls/{pr}/reviews --input -
{
  "comments": [...]
}
EOF
gh api repos/{owner}/{repo}/pulls/{pr}/reviews
--raw-field 'comments[0][path]=file1.tsx'
--raw-field 'comments[0][line]=15'
--raw-field 'comments[1][path]=file2.tsx'
--raw-field 'comments[1][line]=30'

**错误:**
Invalid request. For 'properties/comments', {"0" => {...}, "1" => {...}} is not an array.

**解决方案:** 使用 heredoc 传入JSON输入:

```bash
cat <<'EOF' | gh api repos/{owner}/{repo}/pulls/{pr}/reviews --input -
{
  "comments": [...]
}
EOF

Issue 3: Invalid line number

问题3:无效行号

Error Message:
Pull request review thread line must be part of the diff
Cause: The line number doesn't exist in the diff for this file.
Solutions:
  • Verify the file was actually changed in this PR
  • Check the "Files changed" tab to see actual line numbers in the diff
  • Ensure you're using the correct
    commit_id
    (the latest commit in the PR)
错误信息:
Pull request review thread line must be part of the diff
原因: 该行号不存在于该文件的差异中。
解决方案:
  • 验证该文件是否确实在此PR中被修改
  • 查看"文件变更"标签,确认差异中的实际行号
  • 确保使用了正确的
    commit_id
    (PR中的最新提交)

Issue 4: Wrong commit_id

问题4:错误的commit_id

Error Message:
commit_sha is not part of the pull request
Solution: Get the latest commit SHA:
bash
gh api repos/{owner}/{repo}/pulls/{pr_number} --jq '.head.sha'
错误信息:
commit_sha is not part of the pull request
解决方案: 获取最新的提交SHA值:
bash
gh api repos/{owner}/{repo}/pulls/{pr_number} --jq '.head.sha'

Best Practices

最佳实践

1. Get PR Information First

1. 先获取PR信息

Before adding comments, gather necessary information:
bash
undefined
添加评论前,收集必要的信息:
bash
undefined

Get PR details

获取PR详情

gh pr view {pr_number} --json headRefOid,files
gh pr view {pr_number} --json headRefOid,files

Or use the API

或使用API

gh api repos/{owner}/{repo}/pulls/{pr_number} --jq '{commit: .head.sha, files: [.changed_files]}'
gh api repos/{owner}/{repo}/pulls/{pr_number} --jq '{commit: .head.sha, files: [.changed_files]}'

List files changed

列出变更的文件

gh api repos/{owner}/{repo}/pulls/{pr_number}/files --jq '.[] | {filename: .filename, additions: .additions, deletions: .deletions}'
undefined
gh api repos/{owner}/{repo}/pulls/{pr_number}/files --jq '.[] | {filename: .filename, additions: .additions, deletions: .deletions}'
undefined

2. Check for Pending Reviews

2. 检查待处理评审

bash
undefined
bash
undefined

Check if you have a pending review

检查是否存在待处理的评审

gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews
--jq '.[] | select(.state=="PENDING" and .user.login=="YOUR_USERNAME")'
undefined
gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews
--jq '.[] | select(.state=="PENDING" and .user.login=="YOUR_USERNAME")'
undefined

3. Use Meaningful Comment Text

3. 使用有意义的评论内容

  • Be specific and constructive
  • Reference documentation or best practices
  • Suggest alternatives when requesting changes
  • Use code blocks for code suggestions:
markdown
Consider using async/await:

\`\`\`typescript
async function getData() {
  const result = await fetch(url);
  return result.json();
}
\`\`\`
  • 具体且具有建设性
  • 参考文档或最佳实践
  • 请求修改时提供替代方案
  • 使用代码块给出代码建议:
markdown
考虑使用async/await:

\`\`\`typescript
async function getData() {
  const result = await fetch(url);
  return result.json();
}
\`\`\`

4. Batch Related Comments

4. 批量处理相关评论

Use the review endpoint to group related comments:
  • All comments for a single file/area
  • All comments for a specific concern (security, performance, etc.)
  • Complete review session
使用评审端点对相关评论进行分组:
  • 单个文件/区域的所有评论
  • 针对特定关注点(安全、性能等)的所有评论
  • 完整的评审会话

5. Choose the Right Event Type

5. 选择正确的事件类型

bash
undefined
bash
undefined

For feedback during development

开发过程中的反馈

"event": "COMMENT"
"event": "COMMENT"

When approving

批准时

"event": "APPROVE"
"event": "APPROVE"

When blocking merge

阻止合并时

"event": "REQUEST_CHANGES"
undefined
"event": "REQUEST_CHANGES"
undefined

Workflow Examples

工作流示例

Example 1: Quick Single Comment

示例1:快速添加单个评论

bash
#!/bin/bash
OWNER="NeoLabHQ"
REPO="learning-platform-app"
PR=4
bash
#!/bin/bash
OWNER="NeoLabHQ"
REPO="learning-platform-app"
PR=4

Get latest commit

获取最新提交

COMMIT=$(gh api repos/$OWNER/$REPO/pulls/$PR --jq '.head.sha')
COMMIT=$(gh api repos/$OWNER/$REPO/pulls/$PR --jq '.head.sha')

Add comment

添加评论

gh api repos/$OWNER/$REPO/pulls/$PR/comments
-f body='Consider extracting this into a separate function for better testability'
-f commit_id="$COMMIT"
-f path='src/utils/validation.ts'
-F line=45
-f side='RIGHT'
undefined
gh api repos/$OWNER/$REPO/pulls/$PR/comments
-f body='考虑将此提取为单独的函数,以提高可测试性'
-f commit_id="$COMMIT"
-f path='src/utils/validation.ts'
-F line=45
-f side='RIGHT'
undefined

Example 2: Comprehensive Review

示例2:全面评审

bash
#!/bin/bash
OWNER="NeoLabHQ"
REPO="learning-platform-app"
PR=4
bash
#!/bin/bash
OWNER="NeoLabHQ"
REPO="learning-platform-app"
PR=4

Create review with multiple comments

创建包含多个评论的评审

cat <<EOF | gh api repos/$OWNER/$REPO/pulls/$PR/reviews --input - { "event": "COMMENT", "body": "Thanks for the PR! I've reviewed the changes and have a few suggestions.", "comments": [ { "path": "src/components/CourseCard.tsx", "body": "Consider memoizing this component to prevent unnecessary re-renders", "side": "RIGHT", "line": 25 }, { "path": "src/utils/courseProgress.ts", "body": "This function could benefit from error handling for invalid course IDs", "side": "RIGHT", "line": 12 }, { "path": "src/state/CourseProgressState.ts", "body": "Consider adding JSDoc comments to document the expected behavior", "side": "RIGHT", "line": 8 } ] } EOF
undefined
cat <<EOF | gh api repos/$OWNER/$REPO/pulls/$PR/reviews --input - { "event": "COMMENT", "body": "感谢提交PR!我已评审了变更,有一些建议。", "comments": [ { "path": "src/components/CourseCard.tsx", "body": "考虑对该组件进行记忆化处理,以避免不必要的重渲染", "side": "RIGHT", "line": 25 }, { "path": "src/utils/courseProgress.ts", "body": "此函数可添加针对无效课程ID的错误处理", "side": "RIGHT", "line": 12 }, { "path": "src/state/CourseProgressState.ts", "body": "考虑添加JSDoc注释以记录预期行为", "side": "RIGHT", "line": 8 } ] } EOF
undefined

Example 3: Multi-line Comment

示例3:多行评论

bash
undefined
bash
undefined

Comment on a range of lines (e.g., lines 10-15)

对一系列行进行评论(例如,第10-15行)

gh api repos/$OWNER/$REPO/pulls/$PR/comments
-f body='This entire block could be simplified using array destructuring'
-f commit_id="$COMMIT"
-f path='src/utils/parser.ts'
-F start_line=10
-f start_side='RIGHT'
-F line=15
-f side='RIGHT'
undefined
gh api repos/$OWNER/$REPO/pulls/$PR/comments
-f body='整个代码块可使用数组解构简化'
-f commit_id="$COMMIT"
-f path='src/utils/parser.ts'
-F start_line=10
-f start_side='RIGHT'
-F line=15
-f side='RIGHT'
undefined

Helpful Helper Scripts

实用辅助脚本

Get PR Files and Lines

获取PR文件和行信息

bash
#!/bin/bash
bash
#!/bin/bash

pr-files.sh - List all files changed in a PR with line counts

pr-files.sh - 列出PR中所有变更的文件及行数统计

OWNER="$1" REPO="$2" PR="$3"
gh api repos/$OWNER/$REPO/pulls/$PR/files --jq '.[] | "(.filename): +(.additions)/-(.deletions)"'
undefined
OWNER="$1" REPO="$2" PR="$3"
gh api repos/$OWNER/$REPO/pulls/$PR/files --jq '.[] | "(.filename): +(.additions)/-(.deletions)"'
undefined

Check Review Status

检查评审状态

bash
#!/bin/bash
bash
#!/bin/bash

check-reviews.sh - Check review status for a PR

check-reviews.sh - 检查PR的评审状态

OWNER="$1" REPO="$2" PR="$3"
echo "=== Reviews ===" gh api repos/$OWNER/$REPO/pulls/$PR/reviews --jq '.[] | "(.user.login): (.state) at (.submitted_at)"'
echo -e "\n=== Pending Reviews ===" gh api repos/$OWNER/$REPO/pulls/$PR/reviews --jq '.[] | select(.state=="PENDING") | "(.user.login): (.state)"'
undefined
OWNER="$1" REPO="$2" PR="$3"
echo "=== 评审列表 ===" gh api repos/$OWNER/$REPO/pulls/$PR/reviews --jq '.[] | "(.user.login): (.state) at (.submitted_at)"'
echo -e "\n=== 待处理评审 ===" gh api repos/$OWNER/$REPO/pulls/$PR/reviews --jq '.[] | select(.state=="PENDING") | "(.user.login): (.state)"'
undefined

Related Documentation

相关文档

API Reference

API参考

POST /repos/{owner}/{repo}/pulls/{pull_number}/comments

POST /repos/{owner}/{repo}/pulls/{pull_number}/comments

Creates a review comment on a specific line.
Endpoint:
https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/comments
Parameters:
  • body
    (string, required): Comment text
  • commit_id
    (string, required): SHA of commit
  • path
    (string, required): Relative file path
  • line
    (integer, required): Line number in diff
  • side
    (string, required): "LEFT" or "RIGHT"
  • start_line
    (integer, optional): Start line for multi-line
  • start_side
    (string, optional): Start side for multi-line
在特定行创建评审评论。
端点:
https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/comments
参数:
  • body
    (string,必填):评论文本
  • commit_id
    (string,必填):提交的SHA值
  • path
    (string,必填):文件相对路径
  • line
    (integer,必填):差异中的行号
  • side
    (string,必填):"LEFT"或"RIGHT"
  • start_line
    (integer,可选):多行评论的起始行
  • start_side
    (string,可选):多行评论的起始侧

POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews

POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews

Creates a review with optional line-specific comments.
Endpoint:
https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/reviews
Parameters:
  • event
    (string, required): "APPROVE", "REQUEST_CHANGES", or "COMMENT"
  • body
    (string, optional): Overall review comment
  • comments
    (array, optional): Array of comment objects
  • commit_id
    (string, optional): SHA of commit to review
Comment Object:
  • path
    (string, required): Relative file path
  • body
    (string, required): Comment text
  • line
    (integer, required): Line number in diff
  • side
    (string, required): "LEFT" or "RIGHT"
  • start_line
    (integer, optional): Start line for multi-line
  • start_side
    (string, optional): Start side for multi-line
创建包含可选特定行评论的评审。
端点:
https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/reviews
参数:
  • event
    (string,必填):"APPROVE"、"REQUEST_CHANGES"或"COMMENT"
  • body
    (string,可选):整体评审评论
  • comments
    (array,可选):评论对象数组
  • commit_id
    (string,可选):要评审的提交SHA值
评论对象:
  • path
    (string,必填):文件相对路径
  • body
    (string,必填):评论文本
  • line
    (integer,必填):差异中的行号
  • side
    (string,必填):"LEFT"或"RIGHT"
  • start_line
    (integer,可选):多行评论的起始行
  • start_side
    (string,可选):多行评论的起始侧