From 2078f83cc348c5b149fde1e4614ddc3e5b3d9b93 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 28 Jan 2014 22:37:08 +0100 Subject: adds a --branch= option. The branchename is passed as BRANCH to the rockspec environment --- src/luarocks/command_line.lua | 7 +++++++ src/luarocks/fetch.lua | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 19d04290..f9fba300 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -113,6 +113,13 @@ function run_command(...) die("Invalid entry for --deps-mode.") end + if flags["branch"] then + if flags["branch"] == true or flags["branch"] == "" then + die("Argument error: use --branch=") + end + cfg.branch = flags["branch"] + end + if flags["tree"] then if flags["tree"] == true or flags["tree"] == "" then die("Argument error: use --tree=") diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 7960acb4..e0525dde 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -144,10 +144,15 @@ end function load_local_rockspec(filename, quick) assert(type(filename) == "string") filename = fs.absolute_name(filename) - local rockspec, err = persist.load_into_table(filename) + local rockspec, err = persist.load_into_table(filename, {BRANCH = cfg.branch}) -- temp add BRANCH if not rockspec then return nil, "Could not load rockspec file "..filename.." ("..err..")" end + if rockspec.BRANCH ~= cfg.branch then + return nil, "Invalid rockspec, BRANCH constant was illegally modified by rockspec" + else + rockspec.BRANCH = nil -- remove temporary added field + end local globals = err local ok, err = true, nil -- cgit v1.2.3-55-g6feb