Skip to content

Commit

Permalink
add md5 subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
SandrineP committed Jan 27, 2025
1 parent 57a2c55 commit 71537cc
Showing 3 changed files with 22 additions and 4 deletions.
19 changes: 16 additions & 3 deletions libmamba/src/api/list.cpp
Original file line number Diff line number Diff line change
@@ -26,11 +26,12 @@ namespace mamba
bool no_pip;
bool reverse;
bool explicit_;
bool md5;
};

struct formatted_pkg
{
std::string name, version, build, channel, url;
std::string name, version, build, channel, url, md5;
};

bool compare_alphabetically(const formatted_pkg& a, const formatted_pkg& b)
@@ -199,6 +200,7 @@ namespace mamba
formatted_pkgs.version = package.second.version;
formatted_pkgs.build = package.second.build_string;
formatted_pkgs.url = package.second.package_url;
formatted_pkgs.md5 = package.second.md5;
packages.push_back(formatted_pkgs);
}
}
@@ -210,9 +212,19 @@ namespace mamba
// format and print table
if (options.explicit_)
{
for (auto p : packages)
if (options.md5)
{
std::cout << p.url << std::endl;
for (auto p : packages)
{
std::cout << p.url << "#" << p.md5 << std::endl;
}
}
else
{
for (auto p : packages)
{
std::cout << p.url << std::endl;
}
}
}
else
@@ -258,6 +270,7 @@ namespace mamba
options.no_pip = config.at("no_pip").value<bool>();
options.reverse = config.at("reverse").value<bool>();
options.explicit_ = config.at("explicit").value<bool>();
options.md5 = config.at("md5").value<bool>();

auto channel_context = ChannelContext::make_conda_compatible(config.context());
detail::list_packages(config.context(), regex, channel_context, std::move(options));
5 changes: 5 additions & 0 deletions micromamba/src/list.cpp
Original file line number Diff line number Diff line change
@@ -45,6 +45,11 @@ init_list_parser(CLI::App* subcom, Configuration& config)
));
subcom->add_flag("--explicit", explicit_.get_cli_config<bool>(), explicit_.description());

auto& md5 = config.insert(
Configurable("md5", false).group("cli").description("Add MD5 hashsum when using --explicit")
);
subcom->add_flag("--md5", md5.get_cli_config<bool>(), md5.description());


// TODO: implement this in libmamba/list.cpp
/*auto& canonical = config.insert(Configurable("canonical", false)
2 changes: 1 addition & 1 deletion micromamba/tests/test_create.py
Original file line number Diff line number Diff line change
@@ -1675,6 +1675,7 @@ def test_glob_in_build_string(monkeypatch, tmp_path):
for package in out["actions"]["FETCH"]
)


def test_non_url_encoding(tmp_path):
# Non-regression test for https://github.com/mamba-org/mamba/issues/3737
env_prefix = tmp_path / "env-non_url_encoding"
@@ -1692,4 +1693,3 @@ def test_non_url_encoding(tmp_path):
non_encoded_url_start = "https://conda.anaconda.org/conda-forge/linux-64/x264-1!"
out = helpers.run_env("export", "-p", env_prefix, "--explicit")
assert non_encoded_url_start in out

0 comments on commit 71537cc

Please sign in to comment.