Browse Source

Fix freshnaut for update_names that don't contain a version number

master
mid-kid 8 years ago
parent
commit
cd162a6b49
  1. 34
      astronaut/freshnaut

34
astronaut/freshnaut

@ -74,7 +74,13 @@ function make_regex(filename, version)
-- Returns two regexes, meant to be used in a loop. (See code using this function to know what I mean)
--]]--
local regex = escape_regex(filename:gsub(escape_regex(version), "{{version}}"):gsub("%%", "%%%%"))
local temp_filename = filename:gsub(escape_regex(version), "{{version}}")
if temp_filename == filename then
-- If we can't find version in filename, return.
return nil, nil
end
local regex = escape_regex(temp_filename:gsub("%%", "%%%%"))
return regex:gsub("{{version}}", "(.-") .. ")", regex:gsub(".*{{version}}", "(.-)")
end
@ -118,18 +124,20 @@ function get_available_versions(satellite)
for update_name in update_names:gmatch("[^,]+") do
local loop_regex, end_regex = make_regex(update_name, version)
for x in update_file:gmatch(loop_regex) do
-- Sometimes, the match starts way too soon, and we get a very long "version" number.
-- Here we make sure we really get the shortest possible match.
local version
repeat
version = x
x = x:match(loop_regex)
until not x
version = version:match(end_regex)
versions[version] = true
count = count + 1
if loop_regex and end_regex then
for x in update_file:gmatch(loop_regex) do
-- Sometimes, the match starts way too soon, and we get a very long "version" number.
-- Here we make sure we really get the shortest possible match.
local version
repeat
version = x
x = x:match(loop_regex)
until not x
version = version:match(end_regex)
versions[version] = true
count = count + 1
end
end
end

Loading…
Cancel
Save