From 1f0e55811b54201625f8397d14015048394d0825 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 5 Apr 2018 16:32:58 -0300 Subject: Make pack_installed_rock operate on query objects --- src/luarocks/cmd/pack.lua | 4 +++- src/luarocks/pack.lua | 11 ++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/luarocks/cmd/pack.lua b/src/luarocks/cmd/pack.lua index 3d3cdef5..52b2fbca 100644 --- a/src/luarocks/cmd/pack.lua +++ b/src/luarocks/cmd/pack.lua @@ -5,6 +5,7 @@ local cmd_pack = {} local util = require("luarocks.util") local pack = require("luarocks.pack") +local queries = require("luarocks.queries") cmd_pack.help_summary = "Create a rock, packing sources or binaries." cmd_pack.help_arguments = "{| []}" @@ -33,7 +34,8 @@ function cmd_pack.command(flags, arg, version) file, err = pack.pack_source_rock(arg) else local name = util.adjust_name_and_namespace(arg, flags) - file, err = pack.pack_installed_rock(name, version, flags["tree"]) + local query = queries.new(name, version) + file, err = pack.pack_installed_rock(query, flags["tree"]) end if err then return nil, err diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index a02fb677..60ba4caf 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua @@ -77,13 +77,9 @@ end -- @param tree string or nil: An optional tree to pick the package from. -- @return string or (nil, string): The filename of the resulting -- .src.rock file; or nil and an error message. -function pack.pack_installed_rock(name, version, tree) - assert(type(name) == "string") - assert(type(version) == "string" or not version) +function pack.pack_installed_rock(query, tree) - local query = queries.new(name, version) - local repo, repo_url - name, version, repo, repo_url = search.pick_installed_rock(query, tree) + local name, version, repo, repo_url = search.pick_installed_rock(query, tree) if not name then return nil, version end @@ -152,7 +148,8 @@ function pack.pack_binary_rock(name, version, cmd) if not rname then rname, rversion = name, version end - return pack.pack_installed_rock(rname, rversion, temp_dir) + local query = queries.new(rname, rversion) + return pack.pack_installed_rock(query, temp_dir) end return pack -- cgit v1.2.3-55-g6feb