From 6917132651af3932f0ad255a608d0d1faf6c885c Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Tue, 15 Oct 2024 16:19:17 +0200 Subject: [PATCH] fix: parse env name on adding (#2279) fixes: https://github.com/prefix-dev/pixi/issues/2245 Now parses the environment name --------- Co-authored-by: Julian Hofer --- src/cli/project/environment/add.rs | 8 +++----- tests/common/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cli/project/environment/add.rs b/src/cli/project/environment/add.rs index 8d81ba335..67b8957fc 100644 --- a/src/cli/project/environment/add.rs +++ b/src/cli/project/environment/add.rs @@ -5,7 +5,7 @@ use pixi_manifest::EnvironmentName; #[derive(Parser, Debug)] pub struct Args { /// The name of the environment to add. - pub name: String, + pub name: EnvironmentName, /// Features to add to the environment. #[arg(short, long = "feature")] @@ -25,9 +25,7 @@ pub struct Args { } pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> { - let environment_exists = project - .environment(&EnvironmentName::Named(args.name.clone())) - .is_some(); + let environment_exists = project.environment(&args.name).is_some(); if environment_exists && !args.force { return Err(miette::miette!( help = "use --force to overwrite the existing environment", @@ -38,7 +36,7 @@ pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> { // Add the platforms to the lock-file project.manifest.add_environment( - args.name.clone(), + args.name.as_str().to_string(), args.features, args.solve_group, args.no_default_feature, diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 08d310936..c4b1e5486 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -352,11 +352,11 @@ impl PixiControl { } } - pub fn project_environment_add(&self, name: &str) -> ProjectEnvironmentAddBuilder { + pub fn project_environment_add(&self, name: EnvironmentName) -> ProjectEnvironmentAddBuilder { ProjectEnvironmentAddBuilder { manifest_path: Some(self.manifest_path()), args: project::environment::add::Args { - name: name.to_string(), + name, features: None, solve_group: None, no_default_feature: false,