Fix channel in `PackageInfo` (#3681)

This commit is contained in:
Hind-M 2024-12-12 17:12:05 +01:00 committed by GitHub
parent 384ba6398b
commit a25cde7914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 4 deletions

View File

@ -106,8 +106,8 @@ namespace mamba
{
caches.clear_query_cache(m_package_info);
// need to download this file
LOG_DEBUG << "Adding '" << name() << "' to download targets from '" << channel()
<< "/" << url_path() << "'";
LOG_DEBUG << "Adding '" << name() << "' to download targets from '"
<< hide_secrets(channel()) << "/" << url_path() << "'";
m_tarball_path = m_cache_path / filename();
m_needs_extract = true;
m_needs_download = true;

View File

@ -753,7 +753,7 @@ namespace mamba::download
{
Error error;
error.message = std::string("Could not find mirrors for channel ")
+ p_initial_request->mirror_name;
+ hide_secrets(p_initial_request->mirror_name);
m_attempt_results.push_back(tl::unexpected(std::move(error)));
}
}

View File

@ -69,7 +69,7 @@ namespace mamba::specs
{
out.platform = url.platform_name();
url.clear_platform();
out.channel = util::rstrip(url.str(), '/');
out.channel = util::rstrip(url.str(specs::CondaURL::Credentials::Show), '/');
// Note that we use `rsplit...` instead of `split...`
// because the package name may contain '-'.

View File

@ -52,6 +52,27 @@ namespace
REQUIRE(pkg.channel == "https://conda.anaconda.org/conda-forge");
}
SECTION("http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81"
)
{
static constexpr std::string_view url = "http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81";
auto pkg = PackageInfo::from_url(url).value();
REQUIRE(pkg.name == "_libgcc_mutex");
REQUIRE(pkg.version == "0.1");
REQUIRE(pkg.build_string == "conda_forge");
REQUIRE(pkg.filename == "_libgcc_mutex-0.1-conda_forge.tar.bz2");
REQUIRE(pkg.package_url == url.substr(0, url.rfind('#')));
REQUIRE(pkg.md5 == url.substr(url.rfind('#') + 1));
REQUIRE(pkg.platform == "linux-64");
// Make sure the token is not censored when setting the channel
REQUIRE(
pkg.channel
== "http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel"
);
}
SECTION("https://conda.anaconda.org/conda-forge/linux-64/pkg.conda")
{
static constexpr std::string_view url = "https://conda.anaconda.org/conda-forge/linux-64/pkg.conda";