diff options
author | daurnimator <quae@daurnimator.com> | 2020-09-22 07:42:37 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2020-09-22 07:42:37 +1000 |
commit | f162d2ec3ca13d9e757db9dd6eb0f13979bac74b (patch) | |
tree | ddd57f95caeedbe87d8b5b1b7dad43520a1080b8 | |
parent | 93bec0272c3992b0428b5bda073cf6120be5ff36 (diff) | |
parent | 3c2caae0c2cc683b8346084cae6e1ce530b12573 (diff) | |
download | luarocks-f162d2ec3ca13d9e757db9dd6eb0f13979bac74b.tar.gz luarocks-f162d2ec3ca13d9e757db9dd6eb0f13979bac74b.tar.bz2 luarocks-f162d2ec3ca13d9e757db9dd6eb0f13979bac74b.zip |
Merge remote-tracking branch 'origin/refs/pull/1223/head' into master
-rw-r--r-- | src/luarocks/cmd/new_version.lua | 18 |
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 | ||
27 | If a URL is given, it replaces the one from the old rockspec with the given URL. | 27 | If a URL is given, it replaces the one from the old rockspec with the given URL. |
28 | If a URL is not given and a new version is given, it tries to guess the new URL | 28 | If a URL is not given and a new version is given, it tries to guess the new URL |
29 | by replacing occurrences of the version number in the URL or tag. It also tries | 29 | by replacing occurrences of the version number in the URL or tag; if the guessed |
30 | to download the new URL to determine the new MD5 checksum. | 30 | URL is invalid, the old URL is restored. It also tries to download the new URL |
31 | to determine the new MD5 checksum. | ||
31 | 32 | ||
32 | If a tag is given, it replaces the one from the old rockspec. If there is an old | 33 | If a tag is given, it replaces the one from the old rockspec. If there is an old |
33 | tag but no new one passed, it is guessed in the same way URL is. | 34 | tag 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. |
71 | local function check_url_and_update_md5(out_rs) | 72 | local 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 |