瀏覽代碼

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

default_compile_flags
vector-of-bool 3 年之前
父節點
當前提交
7a7a7db9dd
共有 2 個文件被更改,包括 15 次插入8 次删除
  1. +12
    -4
      src/dds/deps.cpp
  2. +3
    -4
      src/dds/deps.test.cpp

+ 12
- 4
src/dds/deps.cpp 查看文件

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

+ 3
- 4
src/dds/deps.test.cpp 查看文件

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

Loading…
取消
儲存