diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2021-08-13 15:12:52 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-13 15:12:52 -0300 |
| commit | 5a442c2bd307bd7078eb16c6802323e300d80960 (patch) | |
| tree | ac10736ca3520d30638aa0b60c8a942596d19a6d | |
| parent | cdd821167c702627a6baa0b32b855e484f64b123 (diff) | |
| download | luarocks-5a442c2bd307bd7078eb16c6802323e300d80960.tar.gz luarocks-5a442c2bd307bd7078eb16c6802323e300d80960.tar.bz2 luarocks-5a442c2bd307bd7078eb16c6802323e300d80960.zip | |
upload: support uploading pre-packaged .src.rock files (#1321)
upload: support uploading pre-packaged .src.rock files
Co-authored-by: daurnimator <quae@daurnimator.com>
| -rw-r--r-- | spec/upload_spec.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/cmd/upload.lua | 19 |
2 files changed, 20 insertions, 7 deletions
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index e1215d2c..73775992 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua | |||
| @@ -46,6 +46,14 @@ describe("luarocks upload #integration", function() | |||
| 46 | print(run.luarocks("upload " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec " .. test_env.openssl_dirs .. " --api-key=123 --sign", {LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/luarocks_site.lua"})) | 46 | print(run.luarocks("upload " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec " .. test_env.openssl_dirs .. " --api-key=123 --sign", {LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/luarocks_site.lua"})) |
| 47 | end) | 47 | end) |
| 48 | 48 | ||
| 49 | it("with .rockspec and .src.rock", function() | ||
| 50 | assert.is_true(run.luarocks_bool("upload " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.src.rock " .. test_env.openssl_dirs, {LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/luarocks_site.lua"})) | ||
| 51 | end) | ||
| 52 | |||
| 53 | it("with arguments .src.rock and .rockspec out of order", function() | ||
| 54 | assert.is_false(run.luarocks_bool("upload " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.src.rock " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec " .. test_env.openssl_dirs, {LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/luarocks_site.lua"})) | ||
| 55 | end) | ||
| 56 | |||
| 49 | it("rockspec with api-key and skip-pack", function() | 57 | it("rockspec with api-key and skip-pack", function() |
| 50 | assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec " .. test_env.openssl_dirs .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/luarocks_site.lua"})) | 58 | assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec " .. test_env.openssl_dirs .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/luarocks_site.lua"})) |
| 51 | end) | 59 | end) |
diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.lua index da51b401..6b84e452 100644 --- a/src/luarocks/cmd/upload.lua +++ b/src/luarocks/cmd/upload.lua | |||
| @@ -14,6 +14,8 @@ function upload.add_to_parser(parser) | |||
| 14 | :summary("Upload a rockspec to the public rocks repository.") | 14 | :summary("Upload a rockspec to the public rocks repository.") |
| 15 | 15 | ||
| 16 | cmd:argument("rockspec", "Rockspec for the rock to upload.") | 16 | cmd:argument("rockspec", "Rockspec for the rock to upload.") |
| 17 | cmd:argument("src-rock", "A corresponding .src.rock file; if not given it will be generated.") | ||
| 18 | :args("?") | ||
| 17 | 19 | ||
| 18 | cmd:flag("--skip-pack", "Do not pack and send source rock.") | 20 | cmd:flag("--skip-pack", "Do not pack and send source rock.") |
| 19 | cmd:option("--api-key", "Pass an API key. It will be stored for subsequent uses.") | 21 | cmd:option("--api-key", "Pass an API key. It will be stored for subsequent uses.") |
| @@ -73,19 +75,22 @@ function upload.command(args) | |||
| 73 | end | 75 | end |
| 74 | 76 | ||
| 75 | local rock_fname | 77 | local rock_fname |
| 76 | if not args.skip_pack and not is_dev_version(rockspec.version) then | 78 | if args.src_rock then |
| 79 | rock_fname = args.src_rock | ||
| 80 | elseif not args.skip_pack and not is_dev_version(rockspec.version) then | ||
| 77 | util.printout("Packing " .. tostring(rockspec.package)) | 81 | util.printout("Packing " .. tostring(rockspec.package)) |
| 78 | rock_fname, err = pack.pack_source_rock(args.rockspec) | 82 | rock_fname, err = pack.pack_source_rock(args.rockspec) |
| 79 | if not rock_fname then | 83 | if not rock_fname then |
| 80 | return nil, err | 84 | return nil, err |
| 81 | end | 85 | end |
| 82 | if args.sign then | 86 | end |
| 83 | rock_sigfname, err = signing.sign_file(rock_fname) | 87 | |
| 84 | if err then | 88 | if rock_fname and args.sign then |
| 85 | return nil, "Failed signing rock: " .. err | 89 | rock_sigfname, err = signing.sign_file(rock_fname) |
| 86 | end | 90 | if err then |
| 87 | util.printout("Signed packed rock: "..rock_sigfname) | 91 | return nil, "Failed signing rock: " .. err |
| 88 | end | 92 | end |
| 93 | util.printout("Signed packed rock: "..rock_sigfname) | ||
| 89 | end | 94 | end |
| 90 | 95 | ||
| 91 | local multipart = require("luarocks.upload.multipart") | 96 | local multipart = require("luarocks.upload.multipart") |
