Skip to content

Commit

Permalink
fix: parse env name on adding (#2279)
Browse files Browse the repository at this point in the history
fixes: #2245

Now parses the environment name

---------

Co-authored-by: Julian Hofer <julianhofer@gnome.org>
  • Loading branch information
ruben-arts and Hofer-Julian authored Oct 15, 2024
1 parent 7dd06d3 commit 6917132
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/cli/project/environment/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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",
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6917132

Please sign in to comment.