Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some recipe elements case insensitive #983

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/spk-build/src/build/binary_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ async fn test_build_package_options() {
}

#[rstest]
#[case::camel_case("fromBuildEnv")]
#[case::lower_case("frombuildenv")]
#[tokio::test]
async fn test_build_package_pinning() {
async fn test_build_package_pinning(#[case] from_build_env_str: &str) {
let rt = spfs_runtime().await;
let dep_spec = recipe!(
{"pkg": "dep/1.0.0", "build": {"script": "touch /spfs/dep-file"}}
Expand All @@ -210,7 +212,7 @@ async fn test_build_package_pinning() {
],
"options": [{"pkg": "dep/1.0.0"}],
},
"install": {"requirements": [{"pkg": "dep", "fromBuildEnv": "~x.x"}]},
"install": {"requirements": [{"pkg": "dep", from_build_env_str: "~x.x"}]},
}
);

Expand Down
6 changes: 6 additions & 0 deletions crates/spk-schema/crates/foundation/src/option_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ impl std::ops::Deref for Stringified {
}
}

impl std::ops::DerefMut for Stringified {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl<'de> Deserialize<'de> for Stringified {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
Expand Down
9 changes: 5 additions & 4 deletions crates/spk-schema/crates/ident/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,20 @@ impl<'de> Deserialize<'de> for Request {
where
A: serde::de::MapAccess<'de>,
{
while let Some(key) = map.next_key::<Stringified>()? {
while let Some(mut key) = map.next_key::<Stringified>()? {
key.make_ascii_lowercase();
match key.as_str() {
"pkg" => self.pkg = Some(map.next_value::<RangeIdent>()?),
"prereleasePolicy" => {
"prereleasepolicy" => {
self.prerelease_policy = Some(map.next_value::<PreReleasePolicy>()?)
}
"ifPresentInBuildEnv" => {
"ifpresentinbuildenv" => {
self.pin_policy = Some(map.next_value::<PinPolicy>()?)
}
"include" => {
self.inclusion_policy = Some(map.next_value::<InclusionPolicy>()?)
}
"fromBuildEnv" => self.pin = Some(map.next_value::<PinValue>()?),
"frombuildenv" => self.pin = Some(map.next_value::<PinValue>()?),
"var" => {
let NameAndValue(name, value) = map.next_value()?;
self.var = Some(name);
Expand Down
5 changes: 3 additions & 2 deletions crates/spk-schema/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ impl<'de> Deserialize<'de> for Opt {
}
};

while let Some(key) = map.next_key::<Stringified>()? {
while let Some(mut key) = map.next_key::<Stringified>()? {
key.make_ascii_lowercase();
match key.as_str() {
"pkg" => {
let pkg_name_with_components: PkgNameWithComponents =
Expand All @@ -251,7 +252,7 @@ impl<'de> Deserialize<'de> for Opt {
}
self.pkg = Some(pkg_name_with_components);
}
"prereleasePolicy" => {
"prereleasepolicy" => {
self.prerelease_policy = Some(map.next_value::<PreReleasePolicy>()?)
}
"var" => {
Expand Down
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@
"idents",
"ifalreadypresent",
"ifeq",
"ifpresentinbuildenv",
"imath",
"impls",
"inary",
Expand Down Expand Up @@ -573,6 +574,7 @@
"posttags",
"posttrans",
"prctl",
"prereleasepolicy",
"prereleases",
"pretag",
"pretags",
Expand Down
Loading