From 96b6b9ca9cf77922863d440247850b6b7c4bb9ae Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 2 Sep 2019 14:32:54 -0300 Subject: build: fix --branch flag The `--branch` flag is optional and takes a string argument. The `--branch` flag does not make sense for `luarocks make` because it does not fetch sources, it builds/installs based on whatever is in the current directory. This also adds tests that verify the behavior, but these don't run in Travis CI because of issues running a Git daemon there. They were verified locally. --- src/luarocks/build.lua | 15 ++------------- src/luarocks/cmd/build.lua | 6 +++++- src/luarocks/cmd/install.lua | 2 +- src/luarocks/cmd/make.lua | 6 +----- 4 files changed, 9 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 2ac7dd3a..948c5f53 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -18,7 +18,7 @@ build.opts = util.opts_table("build.opts", { deps_mode = "string", build_only_deps = "boolean", namespace = "string?", - branch = "boolean", + branch = "string?", verify = "boolean", }) @@ -337,18 +337,7 @@ local function write_rock_dir_files(rockspec, opts) end --- Build and install a rock given a rockspec. --- @param rockspec_file string: local or remote filename of a rockspec. --- @param need_to_fetch boolean: true if sources need to be fetched, --- false if the rockspec was obtained from inside a source rock. --- @param minimal_mode boolean: true if there's no need to fetch, --- unpack or change dir (this is used by "luarocks make"). Implies --- need_to_fetch = false. --- @param deps_mode string: Dependency mode: "one" for the current default tree, --- "all" for all trees, "order" for all trees with priority >= the current default, --- "none" for no trees. --- @param build_only_deps boolean: true to build the listed dependencies only. --- @param namespace string?: a namespace for the rockspec --- @param branch string?: a forced branch to use +-- @param opts table: build options table -- @return (string, string) or (nil, string, [string]): Name and version of -- installed rock if succeeded or nil and an error message followed by an error code. function build.build_rockspec(rockspec, opts) diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index 57e722b5..ea47cbb0 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua @@ -31,6 +31,10 @@ function cmd_build.add_to_parser(parser) cmd:flag("--only-deps", "Installs only the dependencies of the rock.") cmd:flag("--no-doc", "Installs the rock without its documentation.") + cmd:option("--branch", "Override the `source.branch` field in the loaded ".. + "rockspec. Allows to specify a different branch to fetch. Particularly ".. + 'for "dev" rocks.') + :argname("") make.cmd_options(cmd) end @@ -131,7 +135,7 @@ function cmd_build.command(args) deps_mode = deps.get_deps_mode(args), build_only_deps = not not args.only_deps, namespace = args.namespace, - branch = not not args.branch, + branch = args.branch, verify = not not args.verify, }) diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index 4020918e..be4b0104 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua @@ -42,7 +42,7 @@ function install.add_to_parser(parser) util.deps_mode_option(cmd) -- luarocks build options parser:flag("--pack-binary-rock"):hidden(true) - parser:flag("--branch"):hidden(true) + parser:option("--branch"):hidden(true) parser:flag("--sign"):hidden(true) end diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index 480ec48d..3ff5c277 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua @@ -26,10 +26,6 @@ function make.cmd_options(parser) "previously installed versions if it would break dependencies.") parser:flag("--force-fast", "Like --force, but performs a forced removal ".. "without reporting dependency issues.") - parser:option("--branch", "Override the `source.branch` field in the loaded ".. - "rockspec. Allows to specify a different branch to fetch. Particularly ".. - 'for "dev" rocks.') - :argname("") parser:flag("--verify", "Verify signature of the rockspec or src.rock being ".. "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. "attempt to download the signature as well. Otherwise, the signature ".. @@ -95,7 +91,7 @@ function make.command(args) deps_mode = deps.get_deps_mode(args), build_only_deps = false, namespace = args.namespace, - branch = not not args.branch, + branch = args.branch, verify = not not args.verify, }) -- cgit v1.2.3-55-g6feb