From e46fd3ea1c597c57f69376eb7a136133c3fa393e Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 8 Oct 2017 16:26:47 -0300 Subject: Adds --dev flag for development-branch sub-repositories. (#736) This adds support for easily requesting `dev` modules from LuaRocks.org, as in: ``` luarocks install --dev luafilesystem ``` The list of URLs configured in `rocks_servers` is prepended with a list containing "/dev" in their paths. --- src/luarocks/cmd/help.lua | 2 ++ src/luarocks/command_line.lua | 17 +++++++++++++++-- src/luarocks/core/vers.lua | 1 + src/luarocks/util.lua | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/luarocks/cmd/help.lua b/src/luarocks/cmd/help.lua index b986534c..d58fdcc0 100644 --- a/src/luarocks/cmd/help.lua +++ b/src/luarocks/cmd/help.lua @@ -52,6 +52,8 @@ function help.command(flags, command) util.printout([[ These apply to all commands, as appropriate: + --dev Enable the sub-repositories in rocks servers + for rockspecs of in-development versions --server= Fetch rocks/rockspecs from this server (takes priority over config file) --only-server= Fetch rocks/rockspecs from this server only diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 6a1cc519..9d33fe15 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -10,6 +10,7 @@ local path = require("luarocks.path") local dir = require("luarocks.dir") local deps = require("luarocks.deps") local fs = require("luarocks.fs") +local fun = require("luarocks.fun") local program = util.this_program("luarocks") @@ -172,11 +173,23 @@ function command_line.run_command(...) cfg.variables.SCRIPTS_DIR = cfg.deploy_bin_dir if flags["server"] then - local protocol, path = dir.split_url(flags["server"]) - table.insert(cfg.rocks_servers, 1, protocol.."://"..path) + local protocol, pathname = dir.split_url(flags["server"]) + table.insert(cfg.rocks_servers, 1, protocol.."://"..pathname) + end + + if flags["dev"] then + local append_dev = function(s) return dir.path(s, "dev") end + local dev_servers = fun.traverse(cfg.rocks_servers, append_dev) + cfg.rocks_servers = fun.concat(dev_servers, cfg.rocks_servers) end if flags["only-server"] then + if flags["dev"] then + die("--only-server cannot be used with --dev") + end + if flags["server"] then + die("--only-server cannot be used with --server") + end cfg.rocks_servers = { flags["only-server"] } end diff --git a/src/luarocks/core/vers.lua b/src/luarocks/core/vers.lua index 1c016bbb..864cc5b5 100644 --- a/src/luarocks/core/vers.lua +++ b/src/luarocks/core/vers.lua @@ -6,6 +6,7 @@ local require = nil -------------------------------------------------------------------------------- local deltas = { + dev = 120000000, scm = 110000000, cvs = 100000000, rc = -1000, diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 0af23df6..1bc24be7 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -89,6 +89,7 @@ local supported_flags = { ["deps"] = true, ["deps-mode"] = "", ["detailed"] = "\"\"", + ["dev"] = true, ["force"] = true, ["force-fast"] = true, ["from"] = "", -- cgit v1.2.3-55-g6feb