diff --git a/src/packaging.rs b/src/packaging.rs index da6db7c70..7b50f6fba 100644 --- a/src/packaging.rs +++ b/src/packaging.rs @@ -125,7 +125,7 @@ fn copy_license_files( // if a file was copied from the recipe dir, and the work dir, we should // issue a warning for file in copied_files_recipe_dir { - if copied_files_work_dir.contains(&file) { + if copied_files_work_dir.contains(file) { let warn_str = format!("License file from source directory was overwritten by license file from recipe folder ({})", file.display()); tracing::warn!(warn_str); output.record_warning(&warn_str); diff --git a/src/recipe/custom_yaml.rs b/src/recipe/custom_yaml.rs index 1e3108305..5163e1e40 100644 --- a/src/recipe/custom_yaml.rs +++ b/src/recipe/custom_yaml.rs @@ -1251,6 +1251,26 @@ where } } +impl TryConvertNode> for RenderedNode +where + K: Ord + Display + Hash, + RenderedScalarNode: TryConvertNode, + RenderedNode: TryConvertNode, +{ + fn try_convert(&self, name: &str) -> Result, Vec> { + self.as_mapping() + .ok_or_else(|| { + _partialerror!( + *self.span(), + ErrorKind::ExpectedMapping, + help = format!("expected a mapping for `{name}`") + ) + }) + .map_err(|e| vec![e]) + .and_then(|m| m.try_convert(name)) + } +} + impl TryConvertNode> for RenderedMappingNode where K: Ord + Display + Hash, diff --git a/src/recipe/parser/script.rs b/src/recipe/parser/script.rs index abcb721ea..8d15f3c0a 100644 --- a/src/recipe/parser/script.rs +++ b/src/recipe/parser/script.rs @@ -6,8 +6,9 @@ use crate::{ }, recipe::error::{ErrorKind, PartialParsingError}, }; +use indexmap::IndexMap; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::{borrow::Cow, collections::BTreeMap, path::PathBuf}; +use std::{borrow::Cow, path::PathBuf}; /// Defines the script to run to build the package. #[derive(Debug, Default, Clone, PartialEq, Eq)] @@ -15,7 +16,7 @@ pub struct Script { /// The interpreter to use for the script. pub interpreter: Option, /// Environment variables to set in the build environment. - pub env: BTreeMap, + pub env: IndexMap, /// Environment variables to leak into the build environment from the host system that /// contain sensitive information. Use with care because this might make recipes no /// longer reproducible on other machines. @@ -48,8 +49,8 @@ impl Serialize for Script { Object { #[serde(skip_serializing_if = "Option::is_none")] interpreter: Option<&'a String>, - #[serde(skip_serializing_if = "BTreeMap::is_empty")] - env: &'a BTreeMap, + #[serde(skip_serializing_if = "IndexMap::is_empty")] + env: &'a IndexMap, #[serde(skip_serializing_if = "Vec::is_empty")] secrets: &'a Vec, #[serde(skip_serializing_if = "Option::is_none", flatten)] @@ -114,7 +115,7 @@ impl<'de> Deserialize<'de> for Script { #[serde(default)] interpreter: Option, #[serde(default)] - env: BTreeMap, + env: IndexMap, #[serde(default)] secrets: Vec, #[serde(default, flatten)] @@ -164,7 +165,7 @@ impl Script { } /// Get the environment variables to set in the build environment. - pub fn env(&self) -> &BTreeMap { + pub fn env(&self) -> &IndexMap { &self.env } diff --git a/src/recipe/parser/snapshots/rattler_build__recipe__parser__test__test__script_parsing.snap b/src/recipe/parser/snapshots/rattler_build__recipe__parser__test__test__script_parsing.snap index d4d2dd218..acc511a49 100644 --- a/src/recipe/parser/snapshots/rattler_build__recipe__parser__test__test__script_parsing.snap +++ b/src/recipe/parser/snapshots/rattler_build__recipe__parser__test__test__script_parsing.snap @@ -15,8 +15,8 @@ expression: yaml_serde - script: interpreter: bash env: - BAZ: QUX FOO: BAR + BAZ: QUX secrets: - ABC - DEF diff --git a/src/variant_render.rs b/src/variant_render.rs index 148f3b106..4cb646d7b 100644 --- a/src/variant_render.rs +++ b/src/variant_render.rs @@ -276,6 +276,7 @@ impl Stage1Render { Ok(sorted_indices) } + #[allow(clippy::type_complexity)] pub fn into_sorted_outputs( self, ) -> Result)>, VariantError> {