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) -- 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}}", "(.-)") return regex:gsub("{{version}}", "(.-") .. ")", regex:gsub(".*{{version}}", "(.-)")
end end
@ -118,18 +124,20 @@ function get_available_versions(satellite)
for update_name in update_names:gmatch("[^,]+") do for update_name in update_names:gmatch("[^,]+") do
local loop_regex, end_regex = make_regex(update_name, version) local loop_regex, end_regex = make_regex(update_name, version)
for x in update_file:gmatch(loop_regex) do if loop_regex and end_regex then
-- Sometimes, the match starts way too soon, and we get a very long "version" number. for x in update_file:gmatch(loop_regex) do
-- Here we make sure we really get the shortest possible match. -- Sometimes, the match starts way too soon, and we get a very long "version" number.
local version -- Here we make sure we really get the shortest possible match.
repeat local version
version = x repeat
x = x:match(loop_regex) version = x
until not x x = x:match(loop_regex)
version = version:match(end_regex) until not x
version = version:match(end_regex)
versions[version] = true
count = count + 1 versions[version] = true
count = count + 1
end
end end
end end

Loading…
Cancel
Save