Skip to content

Commit 5de59ee

Browse files
committed
Remove unused code in EmbeddedRecipeSpec
As seen from coverage tests. Signed-off-by: J Robert Ray <jrray@jrray.org>
1 parent d1dc29f commit 5de59ee

File tree

1 file changed

+2
-116
lines changed

1 file changed

+2
-116
lines changed

crates/spk-schema/src/v0/embedded_recipe_spec.rs

Lines changed: 2 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// https://github.com/spkenv/spk
44

5-
use std::borrow::Cow;
6-
use std::str::FromStr;
7-
85
use serde::{Deserialize, Serialize};
96
use spk_schema_foundation::IsDefault;
107
use spk_schema_foundation::ident::{AsVersionIdent, VersionIdent};
11-
use spk_schema_foundation::version::{IncompatibleReason, VarOptionProblem};
128

139
use super::TestSpec;
1410
use crate::foundation::name::PkgName;
1511
use crate::foundation::spec_ops::prelude::*;
16-
use crate::foundation::version::{Compat, Compatibility, Version};
17-
use crate::ident::{Satisfy, VarRequest, is_false};
12+
use crate::foundation::version::{Compat, Version};
13+
use crate::ident::is_false;
1814
use crate::metadata::Meta;
1915
use crate::v0::{EmbeddedBuildSpec, EmbeddedInstallSpec, EmbeddedPackageSpec};
2016
use crate::{
@@ -23,7 +19,6 @@ use crate::{
2319
Deprecate,
2420
DeprecateMut,
2521
EnvOp,
26-
Opt,
2722
Result,
2823
RuntimeEnvironment,
2924
SourceSpec,
@@ -54,26 +49,6 @@ pub struct EmbeddedRecipeSpec {
5449
pub install: EmbeddedInstallSpec,
5550
}
5651

57-
impl EmbeddedRecipeSpec {
58-
/// Create an empty spec for the identified package
59-
pub fn new(ident: VersionIdent) -> Self {
60-
Self {
61-
pkg: ident,
62-
meta: Meta::default(),
63-
compat: Compat::default(),
64-
deprecated: bool::default(),
65-
sources: Vec::new(),
66-
build: EmbeddedBuildSpec::default(),
67-
tests: Vec::new(),
68-
install: EmbeddedInstallSpec::default(),
69-
}
70-
}
71-
72-
pub fn build_options(&self) -> Cow<'_, [Opt]> {
73-
Cow::Borrowed(self.build.options.as_slice())
74-
}
75-
}
76-
7752
impl AsVersionIdent for EmbeddedRecipeSpec {
7853
fn as_version_ident(&self) -> &VersionIdent {
7954
self.pkg.as_version_ident()
@@ -128,95 +103,6 @@ impl Versioned for EmbeddedRecipeSpec {
128103
}
129104
}
130105

131-
impl Satisfy<VarRequest> for EmbeddedRecipeSpec
132-
where
133-
Self: Named,
134-
{
135-
fn check_satisfies_request(&self, var_request: &VarRequest) -> Compatibility {
136-
let opt_required = var_request.var.namespace() == Some(self.name());
137-
let mut opt: Option<&Opt> = None;
138-
let request_name = &var_request.var;
139-
for o in self.build.options.iter() {
140-
if request_name == o.full_name() {
141-
opt = Some(o);
142-
break;
143-
}
144-
if request_name == &o.full_name().with_namespace(self.name()) {
145-
opt = Some(o);
146-
break;
147-
}
148-
}
149-
150-
match opt {
151-
None => {
152-
if opt_required {
153-
return Compatibility::Incompatible(IncompatibleReason::VarOptionMissing(
154-
var_request.var.clone(),
155-
));
156-
}
157-
Compatibility::Compatible
158-
}
159-
Some(Opt::Pkg(opt)) => opt.validate(var_request.value.as_pinned()),
160-
Some(Opt::Var(opt)) => {
161-
let request_value = var_request.value.as_pinned();
162-
let exact = opt.get_value(request_value);
163-
if exact.as_deref() == request_value {
164-
return Compatibility::Compatible;
165-
}
166-
167-
// For values that aren't exact matches, if the option specifies
168-
// a compat rule, try treating the values as version numbers
169-
// and see if they satisfy the rule.
170-
if let Some(compat) = &opt.compat {
171-
let base_version = exact.clone();
172-
let Ok(base_version) = Version::from_str(&base_version.unwrap_or_default())
173-
else {
174-
return Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch(
175-
VarOptionProblem::IncompatibleBuildOptionInvalidVersion {
176-
var_request: var_request.var.clone(),
177-
base: exact.unwrap_or_default(),
178-
request_value: request_value.unwrap_or_default().to_string(),
179-
},
180-
));
181-
};
182-
183-
let Ok(request_version) = Version::from_str(request_value.unwrap_or_default())
184-
else {
185-
return Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch(
186-
VarOptionProblem::IncompatibleBuildOptionInvalidVersion {
187-
var_request: var_request.var.clone(),
188-
base: exact.unwrap_or_default(),
189-
request_value: request_value.unwrap_or_default().to_string(),
190-
},
191-
));
192-
};
193-
194-
let result = compat.is_binary_compatible(&base_version, &request_version);
195-
if let Compatibility::Incompatible(incompatible) = result {
196-
return Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch(
197-
VarOptionProblem::IncompatibleBuildOptionWithContext {
198-
var_request: var_request.var.clone(),
199-
exact: exact.unwrap_or_else(|| "None".to_string()),
200-
request_value: request_value.unwrap_or_default().to_string(),
201-
context: Box::new(incompatible),
202-
},
203-
));
204-
}
205-
return result;
206-
}
207-
208-
Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch(
209-
VarOptionProblem::IncompatibleBuildOption {
210-
var_request: var_request.var.clone(),
211-
exact: exact.unwrap_or_else(|| "None".to_string()),
212-
request_value: request_value.unwrap_or_default().to_string(),
213-
},
214-
))
215-
}
216-
}
217-
}
218-
}
219-
220106
impl From<EmbeddedPackageSpec> for EmbeddedRecipeSpec {
221107
fn from(pkg_spec: EmbeddedPackageSpec) -> Self {
222108
Self {

0 commit comments

Comments
 (0)