Skip to content

Commit

Permalink
bundle version downgrading (#184)
Browse files Browse the repository at this point in the history
* bundle version downgrading

* simplify lowest common denominator method
  • Loading branch information
dfrankland authored Nov 27, 2024
1 parent cc55ea1 commit 3e54fd9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
29 changes: 26 additions & 3 deletions bundle/src/bundle_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ pub struct BundleMetaV0_5_29 {
pub base_props: BundleMetaBaseProps,
}

impl From<BundleMetaV0_5_34> for BundleMetaV0_5_29 {
fn from(bundle_meta: BundleMetaV0_5_34) -> Self {
BundleMetaV0_5_29 {
base_props: bundle_meta.base_props,
}
}
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "pyo3", gen_stub_pyclass, pyclass(get_all))]
#[cfg_attr(feature = "wasm", derive(Tsify))]
Expand All @@ -64,6 +72,15 @@ pub struct BundleMetaV0_5_34 {
pub junit_props: BundleMetaJunitProps,
}

impl From<BundleMetaV0_6_2> for BundleMetaV0_5_34 {
fn from(bundle_meta: BundleMetaV0_6_2) -> Self {
BundleMetaV0_5_34 {
base_props: bundle_meta.base_props,
junit_props: bundle_meta.junit_props,
}
}
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "pyo3", gen_stub_pyclass, pyclass(get_all))]
#[cfg_attr(feature = "wasm", derive(Tsify))]
Expand Down Expand Up @@ -103,14 +120,20 @@ pub struct BindingsVersionedBundle(pub VersionedBundle);
#[gen_stub_pymethods]
#[pymethods]
impl BindingsVersionedBundle {
pub fn get_v0_5_29(&self) -> Option<BundleMetaV0_5_29> {
pub fn get_v0_5_29(&self) -> BundleMetaV0_5_29 {
match &self.0 {
VersionedBundle::V0_5_29(bundle_meta) => Some(bundle_meta.clone()),
_ => None,
VersionedBundle::V0_6_2(bundle_meta) => {
BundleMetaV0_5_29::from(BundleMetaV0_5_34::from(bundle_meta.clone()))
}
VersionedBundle::V0_5_34(bundle_meta) => BundleMetaV0_5_29::from(bundle_meta.clone()),
VersionedBundle::V0_5_29(bundle_meta) => bundle_meta.clone(),
}
}
pub fn get_v0_5_34(&self) -> Option<BundleMetaV0_5_34> {
match &self.0 {
VersionedBundle::V0_6_2(bundle_meta) => {
Some(BundleMetaV0_5_34::from(bundle_meta.clone()))
}
VersionedBundle::V0_5_34(bundle_meta) => Some(bundle_meta.clone()),
_ => None,
}
Expand Down
1 change: 0 additions & 1 deletion context-py/tests/test_parse_compressed_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,4 @@ def test_parse_meta_from_tarball():
assert versioned_bundle.get_v0_6_2() is None

bundle_meta = versioned_bundle.get_v0_5_29()
assert bundle_meta is not None
assert bundle_meta.base_props.bundle_upload_id == expected_meta["bundle_upload_id"]

0 comments on commit 3e54fd9

Please sign in to comment.