From 24fa7d2c2c8f9032b66a290be0d2d2623c6904b4 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Mon, 23 May 2016 14:01:37 +0300 Subject: write-rockspec: improve homepage detection * Perform detection later to take into account URL inferred from local scm repo. * Support more protocols instead of just 'git://'. * Support Bitbucket and Gitlab in addition to Github. * Strip trailing '.git'. --- src/luarocks/write_rockspec.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/luarocks/write_rockspec.lua b/src/luarocks/write_rockspec.lua index 9b6593b6..213d1b01 100644 --- a/src/luarocks/write_rockspec.lua +++ b/src/luarocks/write_rockspec.lua @@ -266,10 +266,6 @@ function write_rockspec.run(...) version = version or "scm" local filename = flags["output"] or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") - - if not flags["homepage"] and url_or_dir:match("^git://github.com") then - flags["homepage"] = "http://"..url_or_dir:match("^[^:]+://(.*)") - end local rockspec = { rockspec_format = flags["rockspec-format"], @@ -324,6 +320,19 @@ function write_rockspec.run(...) if not local_dir then local_dir = "." end + + if not flags["homepage"] then + local url_protocol, url_path = dir.split_url(rockspec.source.url) + + if simple_scm_protocols[url_protocol] then + for _, domain in ipairs({"github.com", "bitbucket.org", "gitlab.com"}) do + if util.starts_with(url_path, domain) then + rockspec.description.homepage = "https://"..url_path:gsub("%.git$", "") + break + end + end + end + end local libs = nil if flags["lib"] then -- cgit v1.2.3-55-g6feb