Skip to content

Commit ea54382

Browse files
authored
fix: support dots in owner/repo#issue, and default to github remote with owner, repo (#58)
1 parent 4136a82 commit ea54382

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lua/gx/git.lua

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ function M.get_remote_url(remotes, push, owner, repo)
3535
end
3636
end
3737

38+
if not url and (owner ~= "" and repo ~= "") then -- fallback to github if owner and repo are present
39+
url = "https://github.com/foo/bar"
40+
end
3841
if not url then
3942
notifier.warn("No remote git repository found!")
4043
return

lua/gx/handlers/github.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ local M = {
99

1010
-- navigate to neovim github plugin url
1111
function M.handle(mode, line, handler_options)
12-
local match = helper.find(line, mode, "([%w-_]+/[%w-_]+#%d+)")
12+
local match = helper.find(line, mode, "([%w-_.]+/[%w-_.]+#%d+)")
1313
if not match then
14-
match = helper.find(line, mode, "([%w-_]+#%d+)")
14+
match = helper.find(line, mode, "([%w-_.]+#%d+)")
1515
end
1616
if not match then
1717
match = helper.find(line, mode, "(#%d+)")

test/spec/gx/handlers/github_handler_spec.lua

+6
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ describe("github_handler_does_work", function()
4646
handler.handle("v", "Waiting on upstream neovim/neovim#23943", handler_options)
4747
)
4848
end)
49+
it("parses owner/repo#issue formats with dots", function()
50+
assert.equals(
51+
"https://github.com/chrishrb/gx.nvim/issues/46",
52+
handler.handle("v", "Waiting on upstream chrishrb/gx.nvim#46", handler_options)
53+
)
54+
end)
4955
end)

0 commit comments

Comments
 (0)