| @@ -1,8 +1,10 @@ | |||
| #include "./deps.hpp" | |||
| #include <dds/error/errors.hpp> | |||
| #include <dds/util/log.hpp> | |||
| #include <dds/util/string.hpp> | |||
| #include <boost/leaf/exception.hpp> | |||
| #include <json5/parse_data.hpp> | |||
| #include <semester/walk.hpp> | |||
| @@ -20,12 +22,18 @@ dependency dependency::parse_depends_string(std::string_view str) { | |||
| } | |||
| 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 { | |||
| auto rng = semver::range::parse_restricted(range_str); | |||
| return dependency{std::string(name), {rng.low(), rng.high()}}; | |||
| @@ -11,11 +11,10 @@ TEST_CASE("Parse dependency strings") { | |||
| }; | |||
| 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", "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); | |||