Skip to content

Commit

Permalink
fix: also add to patches
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Nov 24, 2023
1 parent 66235f6 commit f41051e
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 1 deletion.
22 changes: 21 additions & 1 deletion crates/rattler_conda_types/src/repo_data/patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_with::{serde_as, skip_serializing_none, OneOrMany};
use std::io;
use std::path::Path;

use crate::{package::ArchiveType, PackageRecord, RepoData};
use crate::{package::ArchiveType, PackageRecord, PackageUrl, RepoData};

/// Represents a Conda repodata patch.
///
Expand Down Expand Up @@ -92,6 +92,10 @@ pub struct PackageRecordPatch {
with = "::serde_with::rust::double_option"
)]
pub license_family: Option<Option<String>>,

/// Package identifiers of packages that are equivalent to this package but from other
/// ecosystems.
pub purls: Option<Vec<PackageUrl>>,
}

/// Repodata patch instructions for a single subdirectory. See [`RepoDataPatch`] for more
Expand Down Expand Up @@ -136,6 +140,9 @@ impl PackageRecord {
if let Some(license_family) = &patch.license_family {
self.license_family = license_family.clone();
}
if let Some(package_urls) = &patch.purls {
self.purls = package_urls.clone();
}
}
}

Expand Down Expand Up @@ -260,4 +267,17 @@ mod test {
// check result
insta::assert_yaml_snapshot!(repodata);
}

#[test]
fn test_patch_purl() {
// test data
let mut repodata = load_test_repodata();
let patch_instructions = load_patch_instructions("patch_instructions_4.json");

// apply patch
repodata.apply_patches(&patch_instructions);

// check result
insta::assert_yaml_snapshot!(repodata);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
source: crates/rattler_conda_types/src/repo_data/patches.rs
assertion_line: 281
expression: repodata
---
info:
subdir: linux-64
packages:
cross-python_emscripten-32-3.10.1-h60d57d3_8.tar.bz2:
build: h60d57d3_8
build_number: 8
depends:
- coreutils
- crossenv >=1.2
- emscripten_emscripten-32
- pip
- python 3.10.*
- rsync
- sed
- setuptools
md5: 07b8bdf69566cd63e6e49759033830ad
name: cross-python_emscripten-32
purls:
- "pkg:pypi/cross-python@3.10.1"
sha256: 50064d294599734090b9a33a2194a94f5d3743325d5bae61fab3fa5151acf0f9
size: 7069
subdir: linux-64
timestamp: 1679045249592
version: 3.10.1
emscripten_emscripten-32-3.1.27-h60d57d3_5.tar.bz2:
build: h60d57d3_5
build_number: 5
depends:
- emsdk
md5: 16f2daa96cb33b21c78f3dbc6d83546f
name: emscripten_emscripten-32
sha256: ab5117990980e5243446c7e83a501cedfc9863c56bbf896e45c77155c84cc3ed
size: 6820
subdir: linux-64
timestamp: 1678986155405
version: 3.1.27
packages.conda:
cross-python_emscripten-32-3.10.1-h60d57d3_8.conda:
build: h60d57d3_8
build_number: 8
depends:
- coreutils
- crossenv >=1.2
- emscripten_emscripten-32
- pip
- python 3.10.*
- rsync
- sed
- setuptools
md5: 07b8bdf69566cd63e6e49759033830ad
name: cross-python_emscripten-32
purls:
- "pkg:pypi/cross-python@3.10.1"
sha256: 12064d294599734090b9a33a2194a94f5d3743325d5bae61fab3fa5151acf0f9
size: 7069
subdir: linux-64
timestamp: 1679045249592
version: 3.10.1
cross-python_emscripten-32-3.12.1-h60d57d3_8.conda:
build: h60d57d3_8
build_number: 8
depends:
- coreutils
- crossenv >=1.2
- emscripten_emscripten-32
- pip
- python 3.12.*
- rsync
- sed
- setuptools
md5: 07b8bdf69566cd63e6e49759033830ad
name: cross-python_emscripten-32
sha256: 12064d294599734090b9a33a2194a94f5d3743325d5bae61fab3fa5151acf0f9
size: 7069
subdir: linux-64
timestamp: 1679045249592
version: 3.10.1
repodata_version: 1

9 changes: 9 additions & 0 deletions test-data/channels/patch/linux-64/patch_instructions_4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"packages": {
"cross-python_emscripten-32-3.10.1-h60d57d3_8.tar.bz2": {
"purls": [
"pkg:pypi/cross-python@3.10.1"
]
}
}
}

0 comments on commit f41051e

Please sign in to comment.