Merge branch 'nightly' of github.com:NeogitOrg/neogit into nightly

This commit is contained in:
Cameron 2024-03-18 23:04:22 +01:00
commit c2619a33ee
2 changed files with 30 additions and 2 deletions

View file

@ -83,7 +83,7 @@ function M.parse(url)
if protocol == "git" then
user = "git"
host = url:match([[@([^:]+)]])
owner = url:match([[:(%w+)/]])
owner = url:match([[:([^/]+)/]])
else
user = url:match([[://(%w+):?%w*@]]) -- Strip passwords.
port = url:match([[:(%d+)]])
@ -102,7 +102,7 @@ function M.parse(url)
owner = path -- Strictly for backwards compatibility.
end
repository = url:match([[/(%w+)%.git]])
repository = url:match([[/([^/]+)%.git]])
end
return {

View file

@ -133,5 +133,33 @@ describe("lib.git.remote", function()
url = "https://gitlab.priv:4443/project/path/repo.git",
})
end)
it("can parse 'git@github.com:owner-with-dashes/repo.git'", function()
local url = "git@github.com:owner-with-dashes/repo.git"
assert.are.same(git.remote.parse(url), {
host = "github.com",
owner = "owner-with-dashes",
protocol = "git",
repo = "repo",
repository = "repo",
url = "git@github.com:owner-with-dashes/repo.git",
user = "git",
})
end)
it("can parse 'git@github.com:owner/repo-with_specials.git'", function()
local url = "git@github.com:owner/repo-with_specials.git"
assert.are.same(git.remote.parse(url), {
host = "github.com",
owner = "owner",
protocol = "git",
repo = "repo-with_specials",
repository = "repo-with_specials",
url = "git@github.com:owner/repo-with_specials.git",
user = "git",
})
end)
end)
end)