Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build trailing * display #3619

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions libmamba/src/solver/problems_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,18 +1322,28 @@ namespace mamba::solver
return arr;
}

auto rstrip_excessive_free(std::string_view str) -> std::string_view
{
str = util::rstrip(str);
str = util::remove_suffix(str, specs::GlobSpec::free_pattern);
str = util::rstrip(str);
for (const auto& suffix : sorted_suffix(specs::VersionSpec::all_free_strs))
{
str = util::remove_suffix(str, suffix);
}
str = util::rstrip(str);
return str;
}
// Single dependency with only name constraint often end up looking like
// ``python =* *`` so `rstrip_excessive_free` was used to strip all this.
// Best would be to handle this with a richer NamedList that contains
// ``VersionSpecs`` to avoid flaky reliance on string modification.

// As `rstrip_excessive_free` side effect was to strip `*` from a regex,
// (which is not wanted and confusing when trying to understand the
// unsolvability problems), it is not used anymore on `vers_builds_trunc`.
// But we still keep it uncommented for a while (in case we need to
// restore it later).
// auto rstrip_excessive_free(std::string_view str) -> std::string_view
// {
// str = util::rstrip(str);
// str = util::remove_suffix(str, specs::GlobSpec::free_pattern);
// str = util::rstrip(str);
// for (const auto& suffix : sorted_suffix(specs::VersionSpec::all_free_strs))
// {
// str = util::remove_suffix(str, suffix);
// }
// str = util::rstrip(str);
// return str;
// }

void TreeExplainer::write_pkg_dep(const TreeNode& tn)
{
Expand All @@ -1348,11 +1358,7 @@ namespace mamba::solver
}
else
{
// Single dependency with only name constraint often end up looking like
// ``python =* *`` so we strip all this.
// Best would be to handle this with a richer NamedList that contains
// ``VersionSpecs`` to avoid flaky reliance on string modification.
const auto relevant_vers_builds_trunc = rstrip_excessive_free(vers_builds_trunc);
const auto relevant_vers_builds_trunc = vers_builds_trunc;
if (relevant_vers_builds_trunc.empty())
{
write(fmt::format(style, "{}", edges.name()));
Expand Down
28 changes: 28 additions & 0 deletions libmamba/tests/src/solver/libsolv/test_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,5 +1097,33 @@ TEST_SUITE("solver::libsolv::solver")
CHECK_EQ(std::get<Solution::Install>(solution.actions.front()).install.build_string, "bld");
CHECK_EQ(std::get<Solution::Install>(solution.actions.front()).install.build_number, 4);
}

SUBCASE("foo[version='=*,=*', build='pyhd*']")
{
auto pkg = PackageInfo("foo");
pkg.version = "=*,=*";
pkg.build_string = "pyhd*";

db.add_repo_from_packages(std::array{ pkg });

auto request = Request{
/* .flags= */ {},
/* .jobs= */ { Request::Install{ "foo[version='=*,=*', build='pyhd*']"_ms } },
};
const auto outcome = libsolv::Solver().solve(db, request);

REQUIRE(outcome.has_value());
REQUIRE(std::holds_alternative<libsolv::UnSolvable>(outcome.value()));

const auto& unsolvable = std::get<libsolv::UnSolvable>(outcome.value());
const auto problems_explained = unsolvable.explain_problems(db, {});
// To avoid mismatch due to color formatting, we perform the check by splitting the
// output following the format
CHECK(util::contains(problems_explained, "foo =*,=* pyhd*"));
CHECK(util::contains(
problems_explained,
"does not exist (perhaps a typo or a missing channel)."
));
}
}
}
Loading