From 2047e1434e882cebb484ecd536650d3f44d084b3 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Wed, 2 Aug 2023 20:27:14 +0200 Subject: [PATCH] fix: superfluous quotes in lockfile --- .../src/conda_lock/content_hash.rs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/crates/rattler_conda_types/src/conda_lock/content_hash.rs b/crates/rattler_conda_types/src/conda_lock/content_hash.rs index af8a2005a..20d0ae197 100644 --- a/crates/rattler_conda_types/src/conda_lock/content_hash.rs +++ b/crates/rattler_conda_types/src/conda_lock/content_hash.rs @@ -1,6 +1,5 @@ use crate::conda_lock::Channel; use crate::{MatchSpec, Platform}; -use rattler_digest::serde::SerializableHash; use serde::Serialize; use serde_json_python_formatter::PythonFormatter; use std::string::FromUtf8Error; @@ -108,10 +107,9 @@ pub fn calculate_content_hash( channels: &[Channel], ) -> Result { let content_data = calculate_content_data(platform, input_specs, channels)?; - let json_str = serde_json::to_string(&SerializableHash::( - rattler_digest::compute_bytes_digest::(&content_data), - ))?; - Ok(json_str) + let content_hash = + rattler_digest::compute_bytes_digest::(&content_data); + Ok(format!("{:x}", content_hash)) } #[cfg(test)] @@ -122,7 +120,7 @@ mod tests { use crate::{MatchSpec, Platform}; #[test] - fn test_content_hash() { + fn test_content_data() { let output = content_hash::calculate_content_data( &Platform::Osx64, &[MatchSpec::from_str("python =3.11.0").unwrap()], @@ -140,4 +138,19 @@ mod tests { // TODO: add actual hash output checking when we have a default virtual package list //assert_eq!() } + + #[test] + fn test_content_hash() { + let output = content_hash::calculate_content_hash( + &Platform::Osx64, + &[MatchSpec::from_str("python =3.11.0").unwrap()], + &["conda-forge".into()], + ) + .unwrap(); + + assert_eq!( + output, + "66c2193c7a9f1172bbd93eaf49119bd478d1408da018b2944974bbc8d85a6a50" + ); + } }