From 8757ab5a663accbd139c9cf10c4878ecd82e3f05 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 21 Sep 2018 11:06:57 -0700 Subject: search: avoid mixing up version and repo in pick_installed_rock --- src/luarocks/search.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 8a79d990..e76d4591 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua @@ -370,7 +370,6 @@ function search.pick_installed_rock(query, given_tree) return nil, table.concat(out) end - local version = nil local repo_url local name, versions @@ -380,15 +379,12 @@ function search.pick_installed_rock(query, given_tree) name, versions = util.sortedpairs(result_tree)() end - --question: what do we do about multiple versions? This should - --give us the latest version on the last repo (which is usually the global one) - for vs, repositories in util.sortedpairs(versions, vers.compare_versions) do - if not version then version = vs end - for _, rp in ipairs(repositories) do repo_url = rp.repo end - end + local version, repositories = util.sortedpairs(versions, vers.compare_versions)() + for _, rp in ipairs(repositories) do repo_url = rp.repo end local repo = tree_map[repo_url] return name, version, repo, repo_url end return search + -- cgit v1.2.3-55-g6feb