fix: Support `conda env export` `no-builds` flag (#3563)

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
This commit is contained in:
Julien Jerphanion 2024-10-22 16:32:41 +02:00 committed by GitHub
parent dfcc7c0bf1
commit d26c7f5632
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -114,7 +114,8 @@ set_env_command(CLI::App* com, Configuration& config)
export_subcom->add_flag("-e,--explicit", explicit_format, "Use explicit format");
export_subcom->add_flag("--no-md5,!--md5", no_md5, "Disable md5");
export_subcom->add_flag("--no-build,!--build", no_build, "Disable the build string in spec");
export_subcom
->add_flag("--no-build,--no-builds,!--build", no_build, "Disable the build string in spec");
export_subcom->add_flag("--channel-subdir", channel_subdir, "Enable channel/subdir in spec");
export_subcom->add_flag(
"--from-history",

View File

@ -73,7 +73,8 @@ def export_env():
@pytest.mark.parametrize("channel_subdir_flag", [None, "--channel-subdir"])
@pytest.mark.parametrize("md5_flag", [None, "--md5", "--no-md5"])
@pytest.mark.parametrize("explicit_flag", [None, "--explicit"])
def test_env_export(export_env, explicit_flag, md5_flag, channel_subdir_flag):
@pytest.mark.parametrize("no_build_flag", [None, "--no-build", "--no-builds"])
def test_env_export(export_env, no_build_flag, explicit_flag, md5_flag, channel_subdir_flag):
flags = filter(None, [explicit_flag, md5_flag, channel_subdir_flag])
output = helpers.run_env("export", "-n", export_env, *flags)
if explicit_flag:
@ -85,7 +86,11 @@ def test_env_export(export_env, explicit_flag, md5_flag, channel_subdir_flag):
assert ret["name"] == export_env
assert "env-create-export" in ret["prefix"]
assert set(ret["channels"]) == {"conda-forge"}
assert "micromamba=0.24.0=0" in str(ret["dependencies"])
assert (
"micromamba=0.24.0\n"
if no_build_flag
else "micromamba=0.24.0=0" in str(ret["dependencies"])
)
if md5_flag == "--md5":
assert re.search(r"micromamba=0.24.0=0\[md5=[a-f0-9]{32}\]", str(ret["dependencies"]))
if channel_subdir_flag: