From 8468f0beac9b792d7e2621f1a78a485ed542fb1d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 21 Jul 2023 16:34:00 +0300 Subject: Ignore version iteration in satisfies() overloads (GH issue #293) --- bpkg/package-query.hxx | 1 - bpkg/satisfaction.cxx | 20 ++++++++++++++++---- bpkg/satisfaction.hxx | 9 +++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) (limited to 'bpkg') diff --git a/bpkg/package-query.hxx b/bpkg/package-query.hxx index 98bb7a0..12456ce 100644 --- a/bpkg/package-query.hxx +++ b/bpkg/package-query.hxx @@ -93,7 +93,6 @@ namespace bpkg using config_repo_fragments = database_map>>; - available_packages find_available (const package_name&, const optional&, diff --git a/bpkg/satisfaction.cxx b/bpkg/satisfaction.cxx index cbcb5a0..4229004 100644 --- a/bpkg/satisfaction.cxx +++ b/bpkg/satisfaction.cxx @@ -34,13 +34,19 @@ namespace bpkg // if (c.min_version) { - int i (ev.compare (*c.min_version, !c.min_version->revision)); + int i (ev.compare (*c.min_version, + !c.min_version->revision, + true /* ignore_iteration */)); + s = c.min_open ? i > 0 : i >= 0; } if (s && c.max_version) { - int i (ev.compare (*c.max_version, !c.max_version->revision)); + int i (ev.compare (*c.max_version, + !c.max_version->revision, + true /* ignore_iteration */)); + s = c.max_open ? i < 0 : i <= 0; } @@ -85,7 +91,10 @@ namespace bpkg version lv (norm (*l.min_version, true /* min */, l.min_open)); version rv (norm (*r.min_version, true /* min */, r.min_open)); - int i (lv.compare (rv, false /* ignore_revision */)); + int i (lv.compare (rv, + false /* ignore_revision */, + true /* ignore_iteration */)); + if (l.min_open) // Doesn't matter if r is min_open or not. // @@ -108,7 +117,10 @@ namespace bpkg version lv (norm (*l.max_version, false /* min */, l.max_open)); version rv (norm (*r.max_version, false /* min */, r.max_open)); - int i (lv.compare (rv, false /* ignore_revision */)); + int i (lv.compare (rv, + false /* ignore_revision */, + true /* ignore_iteration */)); + if (l.max_open) // Doesn't matter if r is max_open or not. // diff --git a/bpkg/satisfaction.hxx b/bpkg/satisfaction.hxx index 8df4580..174e375 100644 --- a/bpkg/satisfaction.hxx +++ b/bpkg/satisfaction.hxx @@ -12,8 +12,13 @@ namespace bpkg { - // Note: all of the following functions expect the package version - // constraints to be complete. + // Notes: + // + // - All of the following functions expect the package version constraints + // to be complete. + // + // - The version iterations are ignored on version comparisons. + // // Return true if version satisfies the constraint. // -- cgit v1.1