Skip to content
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

fix: support dots in owner/repo#issue, and default to github remote with owner, repo #58

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/gx/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function M.get_remote_url(remotes, push, owner, repo)
end
end

if not url and (owner ~= "" and repo ~= "") then -- fallback to github if owner and repo are present
url = "https://github.com/foo/bar"
end
if not url then
notifier.warn("No remote git repository found!")
return
Expand Down
4 changes: 2 additions & 2 deletions lua/gx/handlers/github.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ local M = {

-- navigate to neovim github plugin url
function M.handle(mode, line, handler_options)
local match = helper.find(line, mode, "([%w-_]+/[%w-_]+#%d+)")
local match = helper.find(line, mode, "([%w-_.]+/[%w-_.]+#%d+)")
if not match then
match = helper.find(line, mode, "([%w-_]+#%d+)")
match = helper.find(line, mode, "([%w-_.]+#%d+)")
end
if not match then
match = helper.find(line, mode, "(#%d+)")
Expand Down
6 changes: 6 additions & 0 deletions test/spec/gx/handlers/github_handler_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ describe("github_handler_does_work", function()
handler.handle("v", "Waiting on upstream neovim/neovim#23943", handler_options)
)
end)
it("parses owner/repo#issue formats with dots", function()
assert.equals(
"https://github.com/chrishrb/gx.nvim/issues/46",
handler.handle("v", "Waiting on upstream chrishrb/gx.nvim#46", handler_options)
)
end)
end)