Paginate files and commits in gh pr view --json#13340
Conversation
|
Thanks for your pull request! Unfortunately, it doesn't meet the requirements for review:
Please update your PR to address the above. This PR will be automatically closed in 4 days if these requirements are not met. Full contribution requirements
|
There was a problem hiding this comment.
Pull request overview
Adds pagination to gh pr view --json files and --json commits to avoid silent truncation at 100 items, aligning behavior with existing paginated PR subresources (reviews/comments/closingIssuesReferences).
Changes:
- Extend PR GraphQL fragments for
filesandcommitsto includepageInfo { hasNextPage endCursor }. - Add
PageInfoto thePullRequest.FilesandPullRequest.Commitsresponse structs. - Implement
preloadPrFiles/preloadPrCommitsto fetch subsequent pages and wire them intofinder.Find’s existingerrgrouppreload flow. - Update query builder tests’ expected fragment output for
files.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/cmd/pr/shared/finder.go | Adds concurrent preloading functions to paginate files and commits beyond the first 100 nodes. |
| api/query_builder_test.go | Updates expected compressed query strings to reflect pageInfo being included. |
| api/query_builder.go | Extends prFiles / prCommits fragments with pageInfo. |
| api/queries_pr.go | Adds PageInfo fields to PullRequest.Files and PullRequest.Commits to receive pagination data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func preloadPrFiles(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error { | ||
| if !pr.Files.PageInfo.HasNextPage { | ||
| return nil | ||
| } | ||
|
|
| Commits struct { | ||
| Nodes []api.PullRequestCommit | ||
| PageInfo struct { | ||
| HasNextPage bool | ||
| EndCursor string |
|
Thanks for your pull request! Unfortunately, it doesn't meet the requirements for review:
Please update your PR to address the above. This PR will be automatically closed in 4 days if these requirements are not met. Full contribution requirements
|
|
Reopened as discussed in #13338 (comment) |
`gh pr view --json files` and `gh pr view --json commits` silently
truncate results at 100 items because the initial GraphQL query fetches
only the first page but never follows pagination.
Add PageInfo to the Files and Commits structs, request
pageInfo{hasNextPage,endCursor} in the GraphQL fragments, and add
preloadPrFiles/preloadPrCommits functions that page through remaining
results using the existing errgroup pattern already used by reviews,
comments, and closingIssuesReferences.
Also add the `graphql:"authors(first: 100)"` tag to
PullRequestCommitCommit.Authors so the struct-based pagination query
includes the required argument (the raw GraphQL fragment already had it).
Fixes cli#13338
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
bab3fa6 to
0292162
Compare
gh pr view --json filesand--json commitssilently truncate at 100 items because the initial query never follows pagination.This adds
PageInfoto theFilesandCommitsstructs, requestspageInfoin the GraphQL fragments, and addspreloadPrFiles/preloadPrCommitsthat page through remaining results in the existing errgroup. This matches the pattern already used by reviews, comments, and closingIssuesReferences.Also adds the
graphql:"authors(first: 100)"tag toPullRequestCommitCommit.Authorsso the struct-based pagination query includes the required argument (the raw GraphQL fragment already had it).Fixes #13338