Skip to content

Consider GitHub PR review comments#465

Open
pcahyna wants to merge 2 commits into
psss:mainfrom
pcahyna:github-diff-review-comments
Open

Consider GitHub PR review comments#465
pcahyna wants to merge 2 commits into
psss:mainfrom
pcahyna:github-diff-review-comments

Conversation

@pcahyna
Copy link
Copy Markdown
Contributor

@pcahyna pcahyna commented Apr 2, 2026

Review comments on GitHub PR diffs are different from ordinary comments in the discussion. The latter can be fetched for PRs just as for issues, as every PR is also an issue. But review comments on diffs need to be fetched in a different way - by requesting them from the PR endpoint like https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/comments, not from the issue endpoint like https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/comments . See the API documentation: https://docs.github.com/en/rest/pulls/comments?apiVersion=2026-03-10

The current code has been doing only the latter and not the former, missing review comments on diffs in the GitHub activity report. Fix that.

As an example, consider this repo : https://github.com/pcahyna/filter_test. PRs pcahyna/filter_test#1 and pcahyna/filter_test#2 have review comments (the former from jridky and pcahyna, the latter from pcahyna). But the reports produced by the commands

did --debug --width 120 --config="./pcahyna.did" --since="2026-03-27" --until="2026-03-30" --email ".... ;github:pcahyna"

and

did --debug --width 120 --config="./jridky.did" --since="2026-03-27" --until="2026-03-30" --email ".... ;github:jridky"

contain only nothing and

* Pull requests commented on github: 1
    * pcahyna/filter_test#003 - Dummy commit to attract comments.

respectively (the latter PR because it was commented by jridky in the discussion).

This PR fixes that, the outputs are now

* Pull requests commented on github: 2
    * pcahyna/filter_test#002 - Dummy commit to attract comments.
    * pcahyna/filter_test#001 - Dummy commit to attract comments.

and

* Pull requests commented on github: 2
    * pcahyna/filter_test#003 - Dummy commit to attract comments.
    * pcahyna/filter_test#001 - Dummy commit to attract comments.

respectively.

Note that the review comment appear among "Pull requests commented on github", not "Pull requests reviewed on github" and it is possible that some of them will also appear duplicate in the "Pull requests reviewed on github" section. I decided to include them in the "commented" section, because the filter that produces the "reviewed" section is quite restrictive, as it is of the type:
https://api.github.com/search/issues?q=reviewed-by:pcahyna+-author:pcahyna+closed:2026-03-27..2026-03-30+type:pr+repo:pcahyna/filter_test&per_page=100
Note that it includes only PRs that were not just reviewed but actually closed (this was noted in issue #370) and excludes reviews by the PR authors (which perhaps makes sense for reviews like approvals, but IMO not for review comments on code diffs, as the latter are discussions and should count as activity). I did not want to touch these design choices.

Note also that according to #325 (comment) it is unnecessary to use the PR comments endpoint, as PullRequestsReviewed has a very solid query. I disagree, because of the reasons above - the query is too restrictive.

Comment thread did/plugins/github.py Outdated
# pr_dict is a small dict that contains the actual pull request URL.
# print(f"URL: {pr_dict['url']}")
response = self.request(pr_dict['url'])
# the full PR dict, contains different fields than the issue dict

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable issue_checked is not used.
@pcahyna pcahyna force-pushed the github-diff-review-comments branch 2 times, most recently from c69f0d1 to 18adbef Compare April 2, 2026 11:59
@sandrobonazzola sandrobonazzola force-pushed the github-diff-review-comments branch from 18adbef to 0b7a04c Compare April 3, 2026 11:48
pcahyna added 2 commits April 13, 2026 11:39
Factor out code that checks whether an issue given as an URL has
comments by a user in a given date range.
Review comments on GitHub PR diffs are different from ordinary comments
in the discussion. The latter can be fetched for PRs just as for issues,
as every PR is also an issue. But review comments on diffs need to be
fetched in a different way - by requesting them from the PR endpoint
like https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/comments
not from the issue endpoint like
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/comments .

The current code has been doing only the latter and not the former, missing
review comments on diffs in the GitHub activity report. Fix that.
@pcahyna pcahyna force-pushed the github-diff-review-comments branch from 0b7a04c to 9cf41ed Compare April 13, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants