How to add a comment on a FILE inside a pull request review with other comments #143197
Replies: 1 comment
-
Unfortunately, GitHub’s REST API currently doesn’t allow file-level comments in a review with multiple comments; it’s only possible to make comments on specific lines. This limitation is somewhat frustrating, as the API doesn’t allow combining multiple comments (including file-level comments) into a single review session. Here are a couple of potential workarounds that could help:
Since the POST /repos/{owner}/{repo}/pulls/{pull_number}/comments endpoint supports file-level comments, you can create reviews where each comment is made one-by-one, using separate API requests for each file-level comment. The downside is that each comment will be treated as its own review, so they won't be grouped together in a single review session. gh api
gh api
Example Script to Handle Multiple File-Level Comments Example usage: ./file_review.sh owner repo pull_number "Your comment" path/to/fileowner="your-owner" for file in "${files[@]}"; do Each workaround has limitations, but until GitHub updates their API, these methods can help approximate multi-comment reviews with some organization around file-level feedback, hope it helps!! |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
I have been looking at creating pull request reviews from github cli, but I cannot figure out if there is a way to make a comment on a file (an not a line inside the file) inside a review. The rest API endpoint for comments (see https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request) allows commenting on files but generates a review with a single comment. The endpoint for pull request reviews (see https://docs.github.com/en/rest/pulls/reviews?apiVersion=2022-11-28#create-a-review-for-a-pull-request) allows making multiple comments in one review but does not seem to support commenting on files (i.e. comments filed does not accept "subject_type" for some reason!)
Anybody knows if there is a workaround for this?
Beta Was this translation helpful? Give feedback.
All reactions