fix: address review findings (pagination, case-insensitive bool, docs)
CI / test (pull_request) Successful in 14s
CI / review (gpt-4.1, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 21s
CI / review (gpt-5, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 43s

- ListReviews: full pagination (loops until partial page returned)
- envOrDefaultBool: case-insensitive, whitespace-trimmed
- action.yml: document accepted boolean values
- Tests: verify pagination across multiple pages
This commit is contained in:
Rodin
2026-05-01 20:22:03 -07:00
parent 0d417e068e
commit faf7fa32c4
4 changed files with 71 additions and 17 deletions
+24 -13
View File
@@ -297,21 +297,32 @@ func (c *Client) GetAuthenticatedUser(ctx context.Context) (string, error) {
}
// ListReviews returns all reviews on a pull request.
// Paginates through all pages to ensure no reviews are missed.
func (c *Client) ListReviews(ctx context.Context, owner, repo string, number int) ([]Review, error) {
reqURL := fmt.Sprintf("%s/api/v1/repos/%s/%s/pulls/%d/reviews",
c.baseURL,
url.PathEscape(owner),
url.PathEscape(repo),
number)
body, err := c.doGet(ctx, reqURL)
if err != nil {
return nil, fmt.Errorf("list reviews: %w", err)
const pageSize = 50
var all []Review
for page := 1; ; page++ {
reqURL := fmt.Sprintf("%s/api/v1/repos/%s/%s/pulls/%d/reviews?limit=%d&page=%d",
c.baseURL,
url.PathEscape(owner),
url.PathEscape(repo),
number,
pageSize,
page)
body, err := c.doGet(ctx, reqURL)
if err != nil {
return nil, fmt.Errorf("list reviews (page %d): %w", page, err)
}
var batch []Review
if err := json.Unmarshal(body, &batch); err != nil {
return nil, fmt.Errorf("parse reviews (page %d): %w", page, err)
}
all = append(all, batch...)
if len(batch) < pageSize {
break
}
}
var reviews []Review
if err := json.Unmarshal(body, &reviews); err != nil {
return nil, fmt.Errorf("parse reviews: %w", err)
}
return reviews, nil
return all, nil
}
// DeleteReview deletes a review by ID. The token must belong to the review author.