Pygithub: Create a review comment for a pull request

Created on 27 Dec 2020  路  7Comments  路  Source: PyGithub/PyGithub

A thing I found missing in the PullRequest object

https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#create-a-review-comment-for-a-pull-request

Would it be possible to add it ? Does it already exist ?

Most helpful comment

While I'm at it (I'll close the issue afterwards), how can I access the changes ? The idea being I need to run a regex on each line and post a review comment if needed.

You can get the contents of a repository or file from the contents API.

Also, is it possible to create review comments inside a review group like you can on github ? Like "start review" then "add to review" and finally submit review ?

Yes, through this endpoint you create a review and in the comments field you list all the comments you want to post on the specific lines.

All 7 comments

It already exists although without the comfort-fade preview, so you won't be able to post multi-line comments: https://pygithub.readthedocs.io/en/latest/github_objects/PullRequest.html#github.PullRequest.PullRequest.create_review_comment

Thank you, I was tired so I didn't take a good look at the doc even though I search through it 3 times... I was certain this method was made for something else.. anyway, that's great!

While I'm at it (I'll close the issue afterwards), how can I access the changes ? The idea being I need to run a regex on each line and post a review comment if needed.

Also, is it possible to create review comments inside a review group like you can on github ? Like "start review" then "add to review" and finally submit review ?

Sorry for the poor text quality, sent from my phone :)

While I'm at it (I'll close the issue afterwards), how can I access the changes ? The idea being I need to run a regex on each line and post a review comment if needed.

You can get the contents of a repository or file from the contents API.

Also, is it possible to create review comments inside a review group like you can on github ? Like "start review" then "add to review" and finally submit review ?

Yes, through this endpoint you create a review and in the comments field you list all the comments you want to post on the specific lines.

Thanks !

You can get the contents of a repository or file from the contents API.

About this, is there a way to get the changes of the PR without having to parse the diff url content?

Would https://pygithub.readthedocs.io/en/latest/github_objects/PullRequest.html#github.PullRequest.PullRequest.get_files work ?

Because I only want to parse/regex and comment on the lines that were changed

I'm able to get the changes of the files through gh.get_repo("python/python-docs-fr").get_pull(1035).get_files()[0].patch. Any idea how I can parse it/get the correct line number for the review comment that goes with it ?

Alright then me again resolving my own issue:

print(gh.get_repo("pydocteur/fake-docs").get_pull(15).get_files()[0].patch) has 6 lines.

using gh.get_repo("pydocteur/fake-docs").get_pull(15).create_review_comment("Position 4", lat_commit, "contents.po", 4) will place a comment on the 5th line (4th position because arrays ;) )

so it seems I have everything I need, back to coding, thank you so mucb @dhruvmanila for the help and all the other maintainers of pygithub <3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacquev6 picture jacquev6  路  3Comments

surajjacob picture surajjacob  路  4Comments

mlainez picture mlainez  路  7Comments

PeterJCLaw picture PeterJCLaw  路  6Comments

Borkason picture Borkason  路  4Comments