Browse Source

Don't ask for the package ID with repoman add, we can just get it

default_compile_flags
vector-of-bool 3 years ago
parent
commit
f0be61c689
6 changed files with 16 additions and 51 deletions
  1. +5
    -22
      src/dds/cli/cmd/repoman_add.cpp
  2. +0
    -6
      src/dds/cli/options.cpp
  3. +0
    -1
      src/dds/cli/options.hpp
  4. +2
    -6
      src/dds/pkg/get/get.cpp
  5. +2
    -0
      src/dds/pkg/get/get.hpp
  6. +7
    -16
      tests/test_repoman.py

+ 5
- 22
src/dds/cli/cmd/repoman_add.cpp View File

@@ -14,16 +14,15 @@
namespace dds::cli::cmd {

static int _repoman_add(const options& opts) {
auto pkg_id = dds::pkg_id::parse(opts.repoman.add.pkg_id_str);
auto rpkg = any_remote_pkg::from_url(neo::url::parse(opts.repoman.add.url_str));
auto rpkg = any_remote_pkg::from_url(neo::url::parse(opts.repoman.add.url_str));
auto temp_sdist = get_package_sdist(rpkg);

dds::pkg_listing add_info{
.ident = pkg_id,
.ident = temp_sdist.sdist.manifest.id,
.deps = temp_sdist.sdist.manifest.dependencies,
.description = opts.repoman.add.description,
.remote_pkg = rpkg,
};
auto temp_sdist = get_package_sdist(add_info);

add_info.deps = temp_sdist.sdist.manifest.dependencies;

auto repo = repo_manager::open(opts.repoman.repo_dir);
repo.add_pkg(add_info, opts.repoman.add.url_str);
@@ -39,22 +38,6 @@ int repoman_add(const options& opts) {
dds::capture_exception();
}
},
[](user_error<errc::invalid_pkg_id>,
semver::invalid_version err,
dds::e_invalid_pkg_id_str idstr) -> int {
dds_log(error,
"Package ID string '{}' is invalid, because '{}' is not a valid semantic "
"version string",
idstr.value,
err.string());
write_error_marker("invalid-pkg-id-str-version");
throw;
},
[](user_error<errc::invalid_pkg_id>, dds::e_invalid_pkg_id_str idstr) -> int {
dds_log(error, "Invalid package ID string '{}'", idstr.value);
write_error_marker("invalid-pkg-id-str");
throw;
},
[](dds::e_sqlite3_error_exc,
boost::leaf::match<neo::sqlite3::errc, neo::sqlite3::errc::constraint_unique>,
dds::pkg_id pkid) {

+ 0
- 6
src/dds/cli/options.cpp View File

@@ -423,12 +423,6 @@ struct setup {

void setup_repoman_add_cmd(argument_parser& repoman_add_cmd) {
repoman_add_cmd.add_argument(repoman_repo_dir_arg.dup());
repoman_add_cmd.add_argument({
.help = "The package ID of the package to add",
.valname = "<pkg-id>",
.required = true,
.action = put_into(opts.repoman.add.pkg_id_str),
});
repoman_add_cmd.add_argument({
.help = "URL to add to the repository",
.valname = "<url>",

+ 0
- 1
src/dds/cli/options.hpp View File

@@ -241,7 +241,6 @@ struct options {

/// Options for 'dds repoman add'
struct {
std::string pkg_id_str;
std::string url_str;
std::string description;
} add;

+ 2
- 6
src/dds/pkg/get/get.cpp View File

@@ -12,9 +12,7 @@

using namespace dds;

namespace {

temporary_sdist do_pull_sdist(const any_remote_pkg& rpkg) {
temporary_sdist dds::get_package_sdist(const any_remote_pkg& rpkg) {
auto tmpdir = dds::temporary_dir::create();

rpkg.get_sdist(tmpdir.path());
@@ -29,10 +27,8 @@ temporary_sdist do_pull_sdist(const any_remote_pkg& rpkg) {
return {sd_tmp_dir, sd};
}

} // namespace

temporary_sdist dds::get_package_sdist(const pkg_listing& pkg) {
auto tsd = do_pull_sdist(pkg.remote_pkg);
auto tsd = get_package_sdist(pkg.remote_pkg);
if (!(tsd.sdist.manifest.id == pkg.ident)) {
throw_external_error<errc::sdist_ident_mismatch>(
"The package name@version in the generated source distribution does not match the name "

+ 2
- 0
src/dds/pkg/get/get.hpp View File

@@ -8,7 +8,9 @@ namespace dds {
class pkg_cache;
class pkg_db;
struct pkg_listing;
class any_remote_pkg;

temporary_sdist get_package_sdist(const any_remote_pkg&);
temporary_sdist get_package_sdist(const pkg_listing&);

void get_all(const std::vector<pkg_id>& pkgs, dds::pkg_cache& repo, const pkg_db& cat);

+ 7
- 16
tests/test_repoman.py View File

@@ -13,35 +13,26 @@ def tmp_repo(tmp_path: Path, dds: DDSWrapper) -> Path:
return tmp_path


def test_error_bad_pkg_id(dds: DDSWrapper, tmp_repo: Path) -> None:
with expect_error_marker('invalid-pkg-id-str-version'):
dds.run(['repoman', 'add', tmp_repo, 'foo@bar', 'http://example.com'])

with expect_error_marker('invalid-pkg-id-str'):
dds.run(['repoman', 'add', tmp_repo, 'foo', 'http://example.com'])


def test_add_simple(dds: DDSWrapper, tmp_repo: Path) -> None:
dds.run(['repoman', 'add', tmp_repo, 'neo-fun@0.6.0', 'git+https://github.com/vector-of-bool/neo-fun.git#0.6.0'])
dds.run(['repoman', 'add', tmp_repo, 'git+https://github.com/vector-of-bool/neo-fun.git#0.6.0'])
with expect_error_marker('dup-pkg-add'):
dds.run(
['repoman', 'add', tmp_repo, 'neo-fun@0.6.0', 'git+https://github.com/vector-of-bool/neo-fun.git#0.6.0'])
dds.run(['repoman', 'add', tmp_repo, 'git+https://github.com/vector-of-bool/neo-fun.git#0.6.0'])


def test_add_github(dds: DDSWrapper, tmp_repo: Path) -> None:
dds.run(['repoman', 'add', tmp_repo, 'neo-fun@0.6.0', 'github:vector-of-bool/neo-fun/0.6.0'])
dds.run(['repoman', 'add', tmp_repo, 'github:vector-of-bool/neo-fun/0.6.0'])
with expect_error_marker('dup-pkg-add'):
dds.run(['repoman', 'add', tmp_repo, 'neo-fun@0.6.0', 'github:vector-of-bool/neo-fun/0.6.0'])
dds.run(['repoman', 'add', tmp_repo, 'github:vector-of-bool/neo-fun/0.6.0'])


def test_add_invalid(dds: DDSWrapper, tmp_repo: Path) -> None:
with expect_error_marker('repoman-add-invalid-pkg-url'):
dds.run(['repoman', 'add', tmp_repo, 'foo@1.2.3', 'invalid://google.com/lolwut'])
dds.run(['repoman', 'add', tmp_repo, 'invalid://google.com/lolwut'])


def test_error_double_remove(tmp_repo: Path, dds: DDSWrapper) -> None:
dds.run([
'repoman', '-ltrace', 'add', tmp_repo, 'neo-fun@0.4.0',
'repoman', '-ltrace', 'add', tmp_repo,
'https://github.com/vector-of-bool/neo-fun/archive/0.4.0.tar.gz?__dds_strpcmp=1'
])
dds.run(['repoman', 'remove', tmp_repo, 'neo-fun@0.4.0'])
@@ -52,7 +43,7 @@ def test_error_double_remove(tmp_repo: Path, dds: DDSWrapper) -> None:

def test_pkg_http(http_repo: RepoServer, tmp_project: Project) -> None:
tmp_project.dds.run([
'repoman', '-ltrace', 'add', http_repo.server.root, 'neo-fun@0.4.0',
'repoman', '-ltrace', 'add', http_repo.server.root,
'https://github.com/vector-of-bool/neo-fun/archive/0.4.0.tar.gz?__dds_strpcmp=1'
])
tmp_project.dds.repo_add(http_repo.url)

Loading…
Cancel
Save