#include "./deps.hpp" | #include "./deps.hpp" | ||||
#include <dds/error/errors.hpp> | #include <dds/error/errors.hpp> | ||||
#include <dds/util/log.hpp> | |||||
#include <dds/util/string.hpp> | #include <dds/util/string.hpp> | ||||
#include <boost/leaf/exception.hpp> | |||||
#include <json5/parse_data.hpp> | #include <json5/parse_data.hpp> | ||||
#include <semester/walk.hpp> | #include <semester/walk.hpp> | ||||
} | } | ||||
auto name = str.substr(0, sep_pos); | auto name = str.substr(0, sep_pos); | ||||
if (str[sep_pos] == '@') { | |||||
++sep_pos; | |||||
if (str[sep_pos] != '@') { | |||||
static bool did_warn = false; | |||||
if (!did_warn) { | |||||
dds_log(warn, | |||||
"Dependency version ranges are deprecated. All are treated as " | |||||
"same-major-version. (Parsing dependency '{}')", | |||||
str); | |||||
} | |||||
did_warn = true; | |||||
} | } | ||||
auto range_str = str.substr(sep_pos); | |||||
auto range_str = "^" + std::string(str.substr(sep_pos + 1)); | |||||
try { | try { | ||||
auto rng = semver::range::parse_restricted(range_str); | auto rng = semver::range::parse_restricted(range_str); | ||||
return dependency{std::string(name), {rng.low(), rng.high()}}; | return dependency{std::string(name), {rng.low(), rng.high()}}; |
}; | }; | ||||
auto cur = GENERATE(Catch::Generators::values<case_>({ | auto cur = GENERATE(Catch::Generators::values<case_>({ | ||||
{"foo@1.2.3", "foo", "1.2.3", "1.2.4"}, | |||||
{"foo=1.2.3", "foo", "1.2.3", "1.2.4"}, | |||||
{"foo@1.2.3", "foo", "1.2.3", "2.0.0"}, | |||||
{"foo=1.2.3", "foo", "1.2.3", "2.0.0"}, | |||||
{"foo^1.2.3", "foo", "1.2.3", "2.0.0"}, | {"foo^1.2.3", "foo", "1.2.3", "2.0.0"}, | ||||
{"foo~1.2.3", "foo", "1.2.3", "1.3.0"}, | |||||
{"foo+1.2.3", "foo", "1.2.3", semver::version::max_version().to_string()}, | |||||
{"foo~1.2.3", "foo", "1.2.3", "2.0.0"}, | |||||
})); | })); | ||||
auto dep = dds::dependency::parse_depends_string(cur.depstr); | auto dep = dds::dependency::parse_depends_string(cur.depstr); |