diff options
author | Peter Melnichenko <mpeterval@gmail.com> | 2016-05-25 11:17:14 +0300 |
---|---|---|
committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-05-25 15:01:33 +0300 |
commit | 22c8993ebe5f509ee55b8af6b7a8be147b3884e6 (patch) | |
tree | 1bce4707ef72c099edfa467867ee2d940d56c928 | |
parent | f41e1da03b2c2aaf4c145ff83d10dfa07c2395ca (diff) | |
download | luarocks-22c8993ebe5f509ee55b8af6b7a8be147b3884e6.tar.gz luarocks-22c8993ebe5f509ee55b8af6b7a8be147b3884e6.tar.bz2 luarocks-22c8993ebe5f509ee55b8af6b7a8be147b3884e6.zip |
luarocks new-version: make rockspec arg optional
Infer it same way `luarocks make` does.
-rw-r--r-- | src/luarocks/new_version.lua | 13 | ||||
-rwxr-xr-x | test/testing.sh | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/luarocks/new_version.lua b/src/luarocks/new_version.lua index 6969d4b2..3382b85c 100644 --- a/src/luarocks/new_version.lua +++ b/src/luarocks/new_version.lua | |||
@@ -11,13 +11,14 @@ local fs = require("luarocks.fs") | |||
11 | local type_check = require("luarocks.type_check") | 11 | local type_check = require("luarocks.type_check") |
12 | 12 | ||
13 | new_version.help_summary = "Auto-write a rockspec for a new version of a rock." | 13 | new_version.help_summary = "Auto-write a rockspec for a new version of a rock." |
14 | new_version.help_arguments = "[--tag=<tag>] {<package>|<rockspec>} [<new_version>] [<new_url>]" | 14 | new_version.help_arguments = "[--tag=<tag>] [<package>|<rockspec>] [<new_version>] [<new_url>]" |
15 | new_version.help = [[ | 15 | new_version.help = [[ |
16 | This is a utility function that writes a new rockspec, updating data | 16 | This is a utility function that writes a new rockspec, updating data |
17 | from a previous one. | 17 | from a previous one. |
18 | 18 | ||
19 | If a package name is given, it downloads the latest rockspec from the | 19 | If a package name is given, it downloads the latest rockspec from the |
20 | default server. If a rockspec is given, it uses it instead. | 20 | default server. If a rockspec is given, it uses it instead. If no argument |
21 | is given, it looks for a rockspec same way 'luarocks make' does. | ||
21 | 22 | ||
22 | If the version number is not given and tag is passed using --tag, | 23 | If the version number is not given and tag is passed using --tag, |
23 | it is used as the version, with 'v' removed from beginning. | 24 | it is used as the version, with 'v' removed from beginning. |
@@ -125,12 +126,16 @@ end | |||
125 | function new_version.run(...) | 126 | function new_version.run(...) |
126 | local flags, input, version, url = util.parse_flags(...) | 127 | local flags, input, version, url = util.parse_flags(...) |
127 | if not input then | 128 | if not input then |
128 | return nil, "Missing argument: expected package or rockspec. "..util.see_help("new_version") | 129 | local err |
130 | input, err = util.get_default_rockspec() | ||
131 | if not input then | ||
132 | return nil, err | ||
133 | end | ||
129 | end | 134 | end |
130 | assert(type(input) == "string") | 135 | assert(type(input) == "string") |
131 | 136 | ||
132 | local filename = input | 137 | local filename = input |
133 | if not input:match(".rockspec$") then | 138 | if not input:match("rockspec$") then |
134 | local err | 139 | local err |
135 | filename, err = download.download("rockspec", input) | 140 | filename, err = download.download("rockspec", input) |
136 | if not filename then | 141 | if not filename then |
diff --git a/test/testing.sh b/test/testing.sh index f56f2aa9..cb10441c 100755 --- a/test/testing.sh +++ b/test/testing.sh | |||
@@ -363,7 +363,6 @@ fail_unpack_noarg() { $luarocks unpack; } | |||
363 | fail_upload_noarg() { $luarocks upload; } | 363 | fail_upload_noarg() { $luarocks upload; } |
364 | fail_remove_noarg() { $luarocks remove; } | 364 | fail_remove_noarg() { $luarocks remove; } |
365 | fail_doc_noarg() { $luarocks doc; } | 365 | fail_doc_noarg() { $luarocks doc; } |
366 | fail_new_version_noarg() { $luarocks new_version; } | ||
367 | 366 | ||
368 | fail_build_invalid() { $luarocks build invalid; } | 367 | fail_build_invalid() { $luarocks build invalid; } |
369 | fail_download_invalid() { $luarocks download invalid; } | 368 | fail_download_invalid() { $luarocks download invalid; } |
@@ -446,6 +445,7 @@ test_make_pack_binary_rock() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks downlo | |||
446 | test_new_version() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec 0.2 && rm ./luacov-0.*; } | 445 | test_new_version() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec 0.2 && rm ./luacov-0.*; } |
447 | test_new_version_url() { $luarocks download --rockspec abelhas 1.0 && $luarocks new_version ./abelhas-1.0-1.rockspec 1.1 https://github.com/downloads/ittner/abelhas/abelhas-1.1.tar.gz && rm ./abelhas-*; } | 446 | test_new_version_url() { $luarocks download --rockspec abelhas 1.0 && $luarocks new_version ./abelhas-1.0-1.rockspec 1.1 https://github.com/downloads/ittner/abelhas/abelhas-1.1.tar.gz && rm ./abelhas-*; } |
448 | test_new_version_tag() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec --tag v0.3 && rm ./luacov-0.3-1.rockspec; } | 447 | test_new_version_tag() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec --tag v0.3 && rm ./luacov-0.3-1.rockspec; } |
448 | test_new_version_tag_without_arg() { rm -rf ./*rockspec && $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version --tag v0.3 && rm ./luacov-0.3-1.rockspec; } | ||
449 | 449 | ||
450 | test_pack() { $luarocks list && $luarocks pack luacov && rm ./luacov-*.rock; } | 450 | test_pack() { $luarocks list && $luarocks pack luacov && rm ./luacov-*.rock; } |
451 | test_pack_src() { $luarocks install $luasec && $luarocks download --rockspec luasocket && $luarocks pack ./luasocket-${verrev_luasocket}.rockspec && rm ./luasocket-${version_luasocket}-*.rock; } | 451 | test_pack_src() { $luarocks install $luasec && $luarocks download --rockspec luasocket && $luarocks pack ./luasocket-${verrev_luasocket}.rockspec && rm ./luasocket-${version_luasocket}-*.rock; } |