Selaa lähdekoodia

The `depends` key is optional in JSON import

default_compile_flags
vector-of-bool 4 vuotta sitten
vanhempi
commit
07ca7e03d9
2 muutettua tiedostoa jossa 25 lisäystä ja 16 poistoa
  1. +19
    -16
      src/dds/catalog/catalog.cpp
  2. +6
    -0
      tests/catalog/import_test.py

+ 19
- 16
src/dds/catalog/catalog.cpp Näytä tiedosto

@@ -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 Näytä tiedosto

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

Loading…
Peruuta
Tallenna