Skip to content

Commit

Permalink
paginate all REST responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Muñoz committed Jan 12, 2024
1 parent adbec48 commit 75aba19
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 353 deletions.
30 changes: 15 additions & 15 deletions lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,14 @@ function M.add_comment()
viewerCanDelete = true,
viewerDidAuthor = true,
reactionGroups = {
{ content = "THUMBS_UP", users = { totalCount = 0 } },
{ content = "THUMBS_UP", users = { totalCount = 0 } },
{ content = "THUMBS_DOWN", users = { totalCount = 0 } },
{ content = "LAUGH", users = { totalCount = 0 } },
{ content = "HOORAY", users = { totalCount = 0 } },
{ content = "CONFUSED", users = { totalCount = 0 } },
{ content = "HEART", users = { totalCount = 0 } },
{ content = "ROCKET", users = { totalCount = 0 } },
{ content = "EYES", users = { totalCount = 0 } },
{ content = "LAUGH", users = { totalCount = 0 } },
{ content = "HOORAY", users = { totalCount = 0 } },
{ content = "CONFUSED", users = { totalCount = 0 } },
{ content = "HEART", users = { totalCount = 0 } },
{ content = "ROCKET", users = { totalCount = 0 } },
{ content = "EYES", users = { totalCount = 0 } },
},
}

Expand Down Expand Up @@ -803,12 +803,12 @@ function M.create_pr(is_draft)

-- get remote branches
if
info == nil
or info.refs == nil
or info.refs.nodes == nil
or info == vim.NIL
or info.refs == vim.NIL
or info.refs.nodes == vim.NIL
info == nil
or info.refs == nil
or info.refs.nodes == nil
or info == vim.NIL
or info.refs == vim.NIL
or info.refs.nodes == vim.NIL
then
utils.error "Cannot grab remote branches"
return
Expand All @@ -824,7 +824,7 @@ function M.create_pr(is_draft)
local remote_branch = local_branch
if not remote_branch_exists then
local choice =
vim.fn.confirm("Remote branch '" .. local_branch .. "' does not exist. Push local one?", "&Yes\n&No\n&Cancel", 2)
vim.fn.confirm("Remote branch '" .. local_branch .. "' does not exist. Push local one?", "&Yes\n&No\n&Cancel", 2)
if choice == 1 then
local remote = "origin"
remote_branch = vim.fn.input {
Expand Down Expand Up @@ -1095,7 +1095,7 @@ function M.show_pr_diff()
end
local url = string.format("/repos/%s/pulls/%s", buffer.repo, buffer.number)
gh.run {
args = { "api", url },
args = { "api", "--paginate", url },
headers = { "Accept: application/vnd.github.v3.diff" },
cb = function(output, stderr)
if stderr and not utils.is_blank(stderr) then
Expand Down
2 changes: 1 addition & 1 deletion lua/octo/model/pull-request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ M.PullRequest = PullRequest
function PullRequest:get_diff(pr)
local url = string.format("repos/%s/pulls/%d", pr.repo, pr.number)
gh.run {
args = { "api", url },
args = { "api", "--paginate", url },
headers = { "Accept: application/vnd.github.v3.diff" },
cb = function(output, stderr)
if stderr and not utils.is_blank(stderr) then
Expand Down
2 changes: 1 addition & 1 deletion lua/octo/pickers/fzf-lua/pickers/changed_files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ return function(opts)
local get_contents = function(fzf_cb)
local url = string.format("repos/%s/pulls/%d/files", buffer.repo, buffer.number)
gh.run {
args = { "api", url },
args = { "api", "--paginate", url },
cb = function(output, stderr)
if stderr and not utils.is_blank(stderr) then
utils.error(stderr)
Expand Down
2 changes: 1 addition & 1 deletion lua/octo/pickers/fzf-lua/pickers/commits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ return function(opts)
local get_contents = function(fzf_cb)
local url = string.format("repos/%s/pulls/%d/commits", buffer.repo, buffer.number)
gh.run {
args = { "api", url },
args = { "api", "--paginate", url },
cb = function(output, stderr)
if stderr and not utils.is_blank(stderr) then
utils.error(stderr)
Expand Down
2 changes: 1 addition & 1 deletion lua/octo/pickers/fzf-lua/previewers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ M.commit = function(formatted_commits, repo)
vim.api.nvim_buf_add_highlight(tmpbuf, -1, "OctoDetailsLabel", 2, 0, string.len "Date:")

local url = string.format("/repos/%s/commits/%s", repo, entry.value)
local cmd = table.concat({ "gh", "api", url, "-H", "'Accept: application/vnd.github.v3.diff'" }, " ")
local cmd = table.concat({ "gh", "api", "--paginate", url, "-H", "'Accept: application/vnd.github.v3.diff'" }, " ")
local proc = io.popen(cmd, "r")
local output
if proc ~= nil then
Expand Down
2 changes: 1 addition & 1 deletion lua/octo/pickers/telescope/previewers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ local commit = defaulter(function(opts)
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines)

local url = string.format("/repos/%s/commits/%s", opts.repo, entry.value)
local cmd = { "gh", "api", url, "-H", "Accept: application/vnd.github.v3.diff" }
local cmd = { "gh", "api", "--paginate", url, "-H", "Accept: application/vnd.github.v3.diff" }
pv_utils.job_maker(cmd, self.state.bufnr, {
value = entry.value,
bufname = self.state.bufname,
Expand Down
Loading

0 comments on commit 75aba19

Please sign in to comment.