Skip to content

Commit

Permalink
Merge branch 'master' into fix/564_better_missing_scope_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pwntester authored Nov 4, 2024
2 parents 847e523 + 8cb88a4 commit b0ab6cd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ require"octo".setup({
enable_builtin = false, -- shows a list of builtin actions when no action is provided
default_remote = {"upstream", "origin"}; -- order to try remotes
default_merge_method = "commit", -- default merge method which should be used when calling `Octo pr merge`, could be `commit`, `rebase` or `squash`
ssh_aliases = {}, -- SSH aliases. e.g. `ssh_aliases = {["github.com-work"] = "github.com"}`
ssh_aliases = {}, -- SSH aliases. e.g. `ssh_aliases = {["github.com-work"] = "github.com"}`. The key part will be interpreted as an anchored Lua pattern.
picker = "telescope", -- or "fzf-lua"
picker_config = {
use_emojis = false, -- only used by "fzf-lua" picker for now
Expand Down Expand Up @@ -411,7 +411,7 @@ If no command is passed, the argument to `Octo` is treated as a URL from where a
- `<CR>`: Append Gist to buffer
[Available keys](https://cli.github.com/manual/gh_gist_list): `repo`\|`public`\|`secret`

5. Users in the assignee and reviewer commands:
5. Users in the assignee and reviewer commands:

- `search`: Dynamically search all GitHub users
- `mentionable`: List of *mentionable* users in current repo
Expand Down
7 changes: 6 additions & 1 deletion lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,15 @@ function M.octo(object, action, ...)
end

local a = o[action] or o
if not pcall(a, ...) then
if not a then
utils.error(action and "Incorrect action: " .. action or "No action specified")
return
end
res = pcall(a, ...)
if not res then
utils.error(action and "Failed action: " .. action)
return
end
end
end

Expand Down
4 changes: 3 additions & 1 deletion lua/octo/pickers/telescope/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ local function open(command)
elseif command == "tab" then
vim.cmd [[:tab sb %]]
end
utils.get(selection.kind, selection.repo, selection.value)
if selection then
utils.get(selection.kind, selection.repo, selection.value)
end
end
end

Expand Down
13 changes: 10 additions & 3 deletions lua/octo/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ function M.is_blank(s)
end

function M.parse_remote_url(url, aliases)
-- filesystem path
if vim.startswith(url, "/") or vim.startswith(url, ".") then
return {
host = nil,
repo = url,
}
end
-- remove trailing ".git"
url = string.gsub(url, ".git$", "")
-- remove protocol scheme
Expand All @@ -174,8 +181,8 @@ function M.parse_remote_url(url, aliases)
repo = chunks[#chunks]
end

if aliases[host] then
host = aliases[host]
for alias, rhost in pairs(aliases) do
host = host:gsub("^" .. alias .. "$", rhost, 1)
end
if not M.is_blank(host) and not M.is_blank(repo) then
return {
Expand Down Expand Up @@ -616,7 +623,7 @@ function M.get_repo_number_from_varargs(...)
return
end
if not repo then
M.error "Cant find repo name"
M.error "Can not find repo name"
return
end
if not number then
Expand Down
4 changes: 4 additions & 0 deletions lua/tests/plenary/utils_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ describe("Utils module:", function()
"[email protected]:pwntester/octo.nvim.git",
"[email protected]:pwntester/octo.nvim.git",
"hub.com:pwntester/octo.nvim.git",
"hub.com-alias:pwntester/octo.nvim.git",
}
local aliases = {
["hub.com"] = "github.com",
["hub.com-.*"] = "github.com",
}
eq(this.parse_remote_url(remote_urls[1], aliases).host, "github.com")
eq(this.parse_remote_url(remote_urls[1], aliases).repo, "pwntester/octo.nvim")
Expand All @@ -24,6 +26,8 @@ describe("Utils module:", function()
eq(this.parse_remote_url(remote_urls[4], aliases).repo, "pwntester/octo.nvim")
eq(this.parse_remote_url(remote_urls[5], aliases).host, "github.com")
eq(this.parse_remote_url(remote_urls[5], aliases).repo, "pwntester/octo.nvim")
eq(this.parse_remote_url(remote_urls[6], aliases).host, "github.com")
eq(this.parse_remote_url(remote_urls[6], aliases).repo, "pwntester/octo.nvim")
end)

it("convert_vim_mapping_to_fzf changes vim mappings to fzf mappings", function()
Expand Down

0 comments on commit b0ab6cd

Please sign in to comment.