From 5a442c2bd307bd7078eb16c6802323e300d80960 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 13 Aug 2021 15:12:52 -0300 Subject: upload: support uploading pre-packaged .src.rock files (#1321) upload: support uploading pre-packaged .src.rock files Co-authored-by: daurnimator --- spec/upload_spec.lua | 8 ++++++++ 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() 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"})) end) + it("with .rockspec and .src.rock", function() + 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"})) + end) + + it("with arguments .src.rock and .rockspec out of order", function() + 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"})) + end) + it("rockspec with api-key and skip-pack", function() 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"})) 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) :summary("Upload a rockspec to the public rocks repository.") cmd:argument("rockspec", "Rockspec for the rock to upload.") + cmd:argument("src-rock", "A corresponding .src.rock file; if not given it will be generated.") + :args("?") cmd:flag("--skip-pack", "Do not pack and send source rock.") cmd:option("--api-key", "Pass an API key. It will be stored for subsequent uses.") @@ -73,19 +75,22 @@ function upload.command(args) end local rock_fname - if not args.skip_pack and not is_dev_version(rockspec.version) then + if args.src_rock then + rock_fname = args.src_rock + elseif not args.skip_pack and not is_dev_version(rockspec.version) then util.printout("Packing " .. tostring(rockspec.package)) rock_fname, err = pack.pack_source_rock(args.rockspec) if not rock_fname then return nil, err end - if args.sign then - rock_sigfname, err = signing.sign_file(rock_fname) - if err then - return nil, "Failed signing rock: " .. err - end - util.printout("Signed packed rock: "..rock_sigfname) + end + + if rock_fname and args.sign then + rock_sigfname, err = signing.sign_file(rock_fname) + if err then + return nil, "Failed signing rock: " .. err end + util.printout("Signed packed rock: "..rock_sigfname) end local multipart = require("luarocks.upload.multipart") -- cgit v1.2.3-55-g6feb