aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-05-23 14:01:37 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-05-23 14:12:11 +0300
commit24fa7d2c2c8f9032b66a290be0d2d2623c6904b4 (patch)
tree52cfe2e8336991c8dc0adfd951f324aa408b25cb
parentb5ee7f79b2d0e54209d714a5eca640d338e17ac6 (diff)
downloadluarocks-24fa7d2c2c8f9032b66a290be0d2d2623c6904b4.tar.gz
luarocks-24fa7d2c2c8f9032b66a290be0d2d2623c6904b4.tar.bz2
luarocks-24fa7d2c2c8f9032b66a290be0d2d2623c6904b4.zip
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'.
-rw-r--r--src/luarocks/write_rockspec.lua17
1 files 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(...)
266 version = version or "scm" 266 version = version or "scm"
267 267
268 local filename = flags["output"] or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") 268 local filename = flags["output"] or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec")
269
270 if not flags["homepage"] and url_or_dir:match("^git://github.com") then
271 flags["homepage"] = "http://"..url_or_dir:match("^[^:]+://(.*)")
272 end
273 269
274 local rockspec = { 270 local rockspec = {
275 rockspec_format = flags["rockspec-format"], 271 rockspec_format = flags["rockspec-format"],
@@ -324,6 +320,19 @@ function write_rockspec.run(...)
324 if not local_dir then 320 if not local_dir then
325 local_dir = "." 321 local_dir = "."
326 end 322 end
323
324 if not flags["homepage"] then
325 local url_protocol, url_path = dir.split_url(rockspec.source.url)
326
327 if simple_scm_protocols[url_protocol] then
328 for _, domain in ipairs({"github.com", "bitbucket.org", "gitlab.com"}) do
329 if util.starts_with(url_path, domain) then
330 rockspec.description.homepage = "https://"..url_path:gsub("%.git$", "")
331 break
332 end
333 end
334 end
335 end
327 336
328 local libs = nil 337 local libs = nil
329 if flags["lib"] then 338 if flags["lib"] then