Suggested Changes

Suggested Changes and Review Comments

A review is a batch of comments submitted together, each attached to a line or range of the diff. A comment with a suggestion block is a suggested change: the block replaces the commented lines when the author commits it. In the browser a review starts on the Files changed tab; a script posts it in one REST call:

A review with a two-line suggestion and a line comment
jq -n '{
  event: "COMMENT",
  body: "Looks good. Two small things before this goes in.",
  comments: [
    { path: "app.js", start_line: 49, line: 50, side: "RIGHT",
      body: ("Match part of the name, in any case, like `?q=` does:\n```suggestion\n"
        + "        params.push(`%${req.query.author}%`);\n"
        + "        clauses.push(`author ILIKE $${params.length}`);\n```") },
    { path: "test/api.test.js", line: 68, side: "RIGHT",
      body: "Please also test a partial, lowercase name such as `?author=nair`." }
  ]
}' > review.json
gh api repos/{owner}/{repo}/pulls/7/reviews --input review.json \
  --jq '"\(.state) review \(.id) by \(.user.login)"'
Output
COMMENTED review 5316701280 by binarybehemoth

side: RIGHT anchors a comment to the new version of the file, and start_line with line spans a range. GitHub 29 renders the suggestion as a small diff of its own:

The review on pull request #7: a suggestion on app.js and a comment on the test
The review on pull request #7: a suggestion on app.js and a comment on the test

The author commits one suggestion with Commit suggestion, or several at once with Add suggestion to batch; each suggester becomes a Co-authored-by co-author. Because the second comment also needed a test, Sam made both changes locally as commit 89dda77 and pushed it to the same branch, which marked the first conversation Outdated, as in the figure.