Browse Source

No more dependency ranges. No everything is same-major-version

default_compile_flags
vector-of-bool 3 years ago
parent
commit
7a7a7db9dd
2 changed files with 15 additions and 8 deletions
  1. +12
    -4
      src/dds/deps.cpp
  2. +3
    -4
      src/dds/deps.test.cpp

+ 12
- 4
src/dds/deps.cpp View File

#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()}};

+ 3
- 4
src/dds/deps.test.cpp View File

}; };


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);

Loading…
Cancel
Save