fix: GHPullRequestReviewComment.getLine() returning -1#2188
fix: GHPullRequestReviewComment.getLine() returning -1#2188Anonycoders wants to merge 6 commits intohub4j:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2188 +/- ##
============================================
+ Coverage 85.03% 85.06% +0.02%
Complexity 2499 2499
============================================
Files 237 237
Lines 7366 7391 +25
Branches 388 389 +1
============================================
+ Hits 6264 6287 +23
- Misses 871 872 +1
- Partials 231 232 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@Anonycoders Great catch here! The comments on the methods and the test showing working behavior are good. However, your comments also make it clear this is a behavior is truly bizarre and likely to cause confusion downstream (even with your comments). I'd like you to consider a couple other options: Option 1: Return classes that match the records
Option 2: Auto-refresh incomplete records, hiding the bad behavior
I think I'd prefer Option 1, it's clear and makes expensive behavior visible. Here's the And here's the full GHPullRequestReviewComment: |
I'd also prefer option No. 1. let me see what I can do about it and shape the PR(s). |
0a7b9ee to
e4b6b37
Compare
|
@bitwiseman I pushed the revised version; let me know what you think about it. |
Description
Problem
When fetching review comments through
review.listReviewComments(), thegetLine()method always returns -1. This is because the GitHub API endpoint/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/commentsdoes not returnline,original_line,side, and related fields.Solution
Introduced a new
GHPullRequestReview.ReviewCommenttype that accurately represents the limited data returned by the review-specific comments endpoint, making the API limitation visible through the type system.New
GHPullRequestReview.ReviewCommentclass — contains only the fields present in the review comments endpoint response (body,path,position, etc.). Users cannot accidentally callgetLine()on this type.readPullRequestReviewComment()method — allows fetching the fullGHPullRequestReviewCommentwith all fields when needed:GHPullRequestReview#listReviewComments()— return type changed fromPagedIterable<GHPullRequestReviewComment>toPagedIterable<GHPullRequestReview.ReviewComment>.getLine(),getSide(), and related methods onGHPullRequestReviewComment, and cross-referenced bothlistReviewComments()methods.Alternative: use GHPullRequest#listReviewComments()
Users who need line data for all comments can use the pull request-level endpoint which returns full
GHPullRequestReviewCommentobjects:Before submitting a PR:
@linkJavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .mvn -D enable-ci clean install site "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"locally. If this command doesn't succeed, your change will not pass CI.main. You will create your PR from that branch.When creating a PR: