-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the Octo pr list
command
#546
base: master
Are you sure you want to change the base?
Improve the Octo pr list
command
#546
Conversation
Prior to this change, we were using the GraphQL resources to retrieve pull requests. This is limited, since there are a number of very useful queries that are not available in GraphQL, including filtering PRs by author or assignee. This change replaces the GraphQL implementation with one based on `gh pr list`, which uses the REST API, and is more functional. This allows filtering by author, assignee, branches (both head and base), state and labels, as well as arbitrary search strings. To handle large repos gracefully, we abandon the attempt to retrieve all pull requests by paginating, since this is potentially unbounded. Instead we fetch at most a configurable limit of pull requests, and expect the user to use filtering on the list to improve relevance.
@@ -127,6 +127,7 @@ function M.get_default_values() | |||
field = "CREATED_AT", | |||
direction = "DESC", | |||
}, | |||
limit = 50, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add to the docs and validate is a number
utils.info "Fetching pull requests (this may take a while) ..." | ||
local args = { | ||
"pr", "list", | ||
"--limit", tostring(opts.limit), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add --paginate
in case limit
is bigger than 100?
pull.author.username = pull.author.login | ||
pull.repository = { nameWithOwner = pull.headRepositoryOwner.login .. "/" .. pull.headRepository.name } | ||
|
||
authors[pull.author.id] = (authors[pull.author.id] or 0) + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im testing Octo pr list
for the neovim/neovim
repo and getting the following error in this line:
Error executing vim.schedule lua callback: ...tester/octo.nvim/lua/octo/pickers/telescope/provider.lua:319: table index is nil
stack traceback:
...tester/octo.nvim/lua/octo/pickers/telescope/provider.lua:319: in function 'cb'
.../src/github.com/pwntester/octo.nvim/lua/octo/gh/init.lua:161: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
Seems like id
may be nil and needs to be handled
Thanks for the PR! added a few comments |
pull.author.username = pull.author.login | ||
pull.repository = { nameWithOwner = pull.headRepositoryOwner.login .. "/" .. pull.headRepository.name } | ||
|
||
authors[pull.author.id] = (authors[pull.author.id] or 0) + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authors[pull.author.id] = (authors[pull.author.id] or 0) + 1 | |
authorid = pull.author.id or 0 | |
authors[pull.author.id] = (authors[pull.author.id] or 0) + 1 |
Thank you! FWIW this works fine for me with the suggested patch. |
Hey @alexkalderimis can you take a look at the review comments and patch provided by @legobeat ? |
@alexkalderimis hi there, are you going to move this forward? if not, I can try to address the comments. |
If you need any support, feel free to tag me. I will be happy to help where I can! |
Resubmitted this with feedback addressed in #635 |
Describe what this PR does / why we need it
This PR includes improvements to the
pr list
command. Specifically:Does this pull request fix one issue?
Fixes #551
Describe how you did it
The main changes are in
pickers/telescope/entry_maker.lua
andpickers/telescope/provider.lua
. These files define both the mechanism for retrieving pull requests and how they are passed to the telescope picker.A new function
gen_from_pull_request
is added inentry_maker.lua
to handle the display of the pull request data, including the addition of the new author and branch columns. Theordinal
for pull requests now includes the author and branch information, allowing this to be used in filtering (displaying this is not enough).The retrieval is changed in
telescope/provider.lua
(specifically in thepull_requests
function). Here we callgh pr list
rather than using the exisiting GraphQL implementation in order to provide access to the additional features that allows.The retrieved records are modified to conform to the GraphQL result schema, meaning that they can be used in existing functions if necessary.
Describe how to verify it
The following actions will be useful in verification:
Octo pr list
and then use telescope to filter by author nameOcto pr list author=@me
and see that only your PRs are shownSpecial notes for reviews