feat(spec): allow git@ and http urls in `Plugin[1]` without `url=`. Fixes #357

This commit is contained in:
Folke Lemaitre 2023-01-09 13:25:50 +01:00
parent d813c518d5
commit 4304035ef4
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 7 additions and 1 deletions

View File

@ -52,8 +52,13 @@ function Spec:add(plugin, results, is_dep)
end end
if not plugin.url and plugin[1] then if not plugin.url and plugin[1] then
local prefix = plugin[1]:sub(1, 4)
if prefix == "http" or prefix == "git@" then
plugin.url = plugin[1]
else
plugin.url = Config.options.git.url_format:format(plugin[1]) plugin.url = Config.options.git.url_format:format(plugin[1])
end end
end
if plugin.dir then if plugin.dir then
plugin.dir = Util.norm(plugin.dir) plugin.dir = Util.norm(plugin.dir)

View File

@ -11,6 +11,7 @@ describe("plugin spec url/name", function()
{ { dir = "~/foo" }, { name = "foo", dir = vim.fn.fnamemodify("~/foo", ":p") } }, { { dir = "~/foo" }, { name = "foo", dir = vim.fn.fnamemodify("~/foo", ":p") } },
{ { dir = "/tmp/foo" }, { dir = "/tmp/foo", name = "foo" } }, { { dir = "/tmp/foo" }, { dir = "/tmp/foo", name = "foo" } },
{ { "foo/bar" }, { [1] = "foo/bar", name = "bar", url = "https://github.com/foo/bar.git" } }, { { "foo/bar" }, { [1] = "foo/bar", name = "bar", url = "https://github.com/foo/bar.git" } },
{ { "https://foo.bar" }, { [1] = "https://foo.bar", name = "foo.bar", url = "https://foo.bar" } },
{ { "foo/bar", name = "foobar" }, { [1] = "foo/bar", name = "foobar", url = "https://github.com/foo/bar.git" } }, { { "foo/bar", name = "foobar" }, { [1] = "foo/bar", name = "foobar", url = "https://github.com/foo/bar.git" } },
{ { "foo/bar", url = "123" }, { [1] = "foo/bar", name = "123", url = "123" } }, { { "foo/bar", url = "123" }, { [1] = "foo/bar", name = "123", url = "123" } },
{ { url = "https://foobar" }, { name = "foobar", url = "https://foobar" } }, { { url = "https://foobar" }, { name = "foobar", url = "https://foobar" } },