topaxi / gh-actions.nvim

See status of workflows and dispatch runs directly in neovim
116 stars 4 forks source link

"curl: (6) Could not resolve host: ssh" #7

Closed bpb closed 5 months ago

bpb commented 5 months ago

Not sure why plenary is fudging up the curl url? Is it expecting http github access?

Error executing luv callback:
....local/share/nvim/lazy/plenary.nvim/lua/plenary/curl.lua:300: get https://ssh/api/v3/repos///github.com/<workspace>/<project>/actions/workflows - curl error exit_code=6 stderr={ "curl: (6) Could not resolve host: ssh" }
stack traceback:
    [C]: in function 'error'
    ....local/share/nvim/lazy/plenary.nvim/lua/plenary/curl.lua:300: in function '_user_on_exit'
    .../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:241: in function '_shutdown'
    .../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:48: in function <.../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:39>
bpb commented 5 months ago

Updating the regex for project extraction fixed the issue for me ([^@/:]+)[:/]([^/]+/[^/]+)$

Also seeing as how you are already leaning on gh cli slightly for token auth I suggest allowing the option for gh api command to make api calls to github.

The reason being some organizations may restrict http based authorization tokens and may require client based OAuth.

It appears that this can be easily done by replacing the fetch function like so if gh is present or selected.

---@param server string
---@param path string
---@param opts? table
function M.fetch(server, path, opts)
  opts = opts or {}
  opts.callback = opts.callback and vim.schedule_wrap(opts.callback)

  local command = string.format("gh api %s", path)
  if opts.method then
    command = command .. " -X " .. opts.method:upper()
  end

  if opts.body then
    command = command .. " -f '" .. vim.json.encode(opts.body) .. "'"
  end

  local res = vim.fn.system(command)
  if opts.callback then
    opts.callback({ body = res })
  end
  return res
end
topaxi commented 5 months ago

I updated the regex to your provided solution.

Happy to accept a PR which updates/changes the fetch method too. I personally do run the the plugin on some machines without the github cli and a manual token though, and would need backwards compatibility on that one.