Parcourir la source

The `depends` key is optional in JSON import

default_compile_flags
vector-of-bool il y a 4 ans
Parent
révision
07ca7e03d9
2 fichiers modifiés avec 25 ajouts et 16 suppressions
  1. +19
    -16
      src/dds/catalog/catalog.cpp
  2. +6
    -0
      tests/catalog/import_test.py

+ 19
- 16
src/dds/catalog/catalog.cpp Voir le fichier

@@ -319,24 +319,27 @@ void catalog::import_json_str(std::string_view content) {
check_json(pkg_info.is_object(),
fmt::format("/packages/{}/{} must be an object", pkg_name, version_));

auto deps = pkg_info["depends"];
check_json(deps.is_object(),
fmt::format("/packages/{}/{}/depends must be an object",
pkg_name,
version_));

package_info info{{pkg_name, version}, {}, {}, {}};
for (const auto& [dep_name, dep_version] : deps.items()) {
check_json(dep_version.is_string(),
fmt::format("/packages/{}/{}/depends/{} must be a string",
auto deps = pkg_info["depends"];

if (!deps.is_null()) {
check_json(deps.is_object(),
fmt::format("/packages/{}/{}/depends must be an object",
pkg_name,
version_,
dep_name));
auto range = semver::range::parse(std::string(dep_version));
info.deps.push_back({
std::string(dep_name),
{range.low(), range.high()},
});
version_));

for (const auto& [dep_name, dep_version] : deps.items()) {
check_json(dep_version.is_string(),
fmt::format("/packages/{}/{}/depends/{} must be a string",
pkg_name,
version_,
dep_name));
auto range = semver::range::parse(std::string(dep_version));
info.deps.push_back({
std::string(dep_name),
{range.low(), range.high()},
});
}
}

auto git_remote = pkg_info["git"];

+ 6
- 0
tests/catalog/import_test.py Voir le fichier

@@ -20,6 +20,12 @@ def test_import_json(dds: DDS):
},
'depends': {},
},
'1.2.5': {
'git': {
'url': 'http://example.com',
'ref': 'master',
},
},
},
},
}

Chargement…
Annuler
Enregistrer