aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cmd/new_version.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/luarocks/cmd/new_version.lua b/src/luarocks/cmd/new_version.lua
index ba85dc03..fc15ef46 100644
--- a/src/luarocks/cmd/new_version.lua
+++ b/src/luarocks/cmd/new_version.lua
@@ -26,8 +26,9 @@ revision number of the given (or downloaded) rockspec.
26 26
27If a URL is given, it replaces the one from the old rockspec with the given URL. 27If a URL is given, it replaces the one from the old rockspec with the given URL.
28If a URL is not given and a new version is given, it tries to guess the new URL 28If a URL is not given and a new version is given, it tries to guess the new URL
29by replacing occurrences of the version number in the URL or tag. It also tries 29by replacing occurrences of the version number in the URL or tag; if the guessed
30to download the new URL to determine the new MD5 checksum. 30URL is invalid, the old URL is restored. It also tries to download the new URL
31to determine the new MD5 checksum.
31 32
32If a tag is given, it replaces the one from the old rockspec. If there is an old 33If a tag is given, it replaces the one from the old rockspec. If there is an old
33tag but no new one passed, it is guessed in the same way URL is. 34tag but no new one passed, it is guessed in the same way URL is.
@@ -68,9 +69,12 @@ end
68-- If it specified MD5, update it. 69-- If it specified MD5, update it.
69-- @return (true, false) if MD5 was not specified or it stayed same, 70-- @return (true, false) if MD5 was not specified or it stayed same,
70-- (true, true) if MD5 changed, (nil, string) on error. 71-- (true, true) if MD5 changed, (nil, string) on error.
71local function check_url_and_update_md5(out_rs) 72local function check_url_and_update_md5(out_rs, invalid_is_error)
72 local file, temp_dir = fetch.fetch_url_at_temp_dir(out_rs.source.url, "luarocks-new-version-"..out_rs.package) 73 local file, temp_dir = fetch.fetch_url_at_temp_dir(out_rs.source.url, "luarocks-new-version-"..out_rs.package)
73 if not file then 74 if not file then
75 if invalid_is_error then
76 return nil, "invalid URL - "..temp_dir
77 end
74 util.warning("invalid URL - "..temp_dir) 78 util.warning("invalid URL - "..temp_dir)
75 return true, false 79 return true, false
76 end 80 end
@@ -118,8 +122,14 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver)
118 if out_rs.source.file then 122 if out_rs.source.file then
119 try_replace(out_rs.source, "file", old_ver, new_ver) 123 try_replace(out_rs.source, "file", old_ver, new_ver)
120 end 124 end
125
126 local old_url = out_rs.source.url
121 if try_replace(out_rs.source, "url", old_ver, new_ver) then 127 if try_replace(out_rs.source, "url", old_ver, new_ver) then
122 return check_url_and_update_md5(out_rs) 128 local ok, md5_changed = check_url_and_update_md5(out_rs, true)
129 if ok then
130 return ok, md5_changed
131 end
132 out_rs.source.url = old_url
123 end 133 end
124 if tag or try_replace(out_rs.source, "tag", old_ver, new_ver) then 134 if tag or try_replace(out_rs.source, "tag", old_ver, new_ver) then
125 return true 135 return true