Skip to content

Commit 41834c9

Browse files
author
Nichol Yip
committed
Fixed changes from rebase
Signed-off-by: Nichol Yip <[email protected]>
1 parent 8dbcc01 commit 41834c9

File tree

4 files changed

+14
-32
lines changed

4 files changed

+14
-32
lines changed

crates/spk-schema/src/build_spec.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use strum::Display;
1515

1616
use super::{v0, Opt, ValidationSpec};
1717
use crate::name::{OptName, OptNameBuf};
18-
use crate::option::VarOpt;
19-
use crate::{Lint, LintedItem, Lints, Result, UnknownKey, Variant};
18+
use crate::option::{PkgOpt, VarOpt};
19+
use crate::{Error, Lint, LintedItem, Lints, Result, UnknownKey, Variant};
2020

2121
#[cfg(test)]
2222
#[path = "./build_spec_test.rs"]
@@ -398,6 +398,7 @@ impl<'de> Deserialize<'de> for BuildSpec {
398398
/// being deserialized must be trusted (eg it's from a repository)
399399
/// but may also not adhere to all of the (potentially new) validation
400400
/// that is done on the normal build spec
401+
#[derive(Default)]
401402
pub(crate) struct UncheckedBuildSpec(BuildSpec);
402403

403404
impl UncheckedBuildSpec {

crates/spk-schema/src/environ.rs

-26
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub enum OpKind {
3434
Prepend,
3535
Priority,
3636
Set,
37-
UnrecognizedKey,
3837
}
3938

4039
/// An operation performed to the environment
@@ -46,7 +45,6 @@ pub enum EnvOp {
4645
Prepend(PrependEnv),
4746
Priority(EnvPriority),
4847
Set(SetEnv),
49-
UnrecognizedKey(UnrecognizedKey),
5048
}
5149

5250
impl EnvOp {
@@ -57,7 +55,6 @@ impl EnvOp {
5755
EnvOp::Prepend(_) => OpKind::Prepend,
5856
EnvOp::Priority(_) => OpKind::Priority,
5957
EnvOp::Set(_) => OpKind::Set,
60-
EnvOp::UnrecognizedKey(_) => OpKind::UnrecognizedKey,
6158
}
6259
}
6360

@@ -68,7 +65,6 @@ impl EnvOp {
6865
EnvOp::Prepend(_) => "",
6966
EnvOp::Priority(_) => "",
7067
EnvOp::Set(_) => "",
71-
EnvOp::UnrecognizedKey(e) => e.error.as_str(),
7268
}
7369
}
7470

@@ -146,7 +142,6 @@ impl EnvOp {
146142
Self::Prepend(op) => op.bash_source(),
147143
Self::Priority(op) => op.bash_source(),
148144
Self::Set(op) => op.bash_source(),
149-
Self::UnrecognizedKey(op) => op.bash_source(),
150145
}
151146
}
152147

@@ -158,7 +153,6 @@ impl EnvOp {
158153
Self::Prepend(op) => op.tcsh_source(),
159154
Self::Priority(op) => op.tcsh_source(),
160155
Self::Set(op) => op.tcsh_source(),
161-
Self::UnrecognizedKey(op) => op.tcsh_source(),
162156
}
163157
}
164158

@@ -230,9 +224,6 @@ impl From<EnvOpVisitor> for EnvOp {
230224
OpKind::Priority => EnvOp::Priority(EnvPriority {
231225
priority: var.get_priority(),
232226
}),
233-
OpKind::UnrecognizedKey => EnvOp::UnrecognizedKey(UnrecognizedKey {
234-
error: var.get_op(),
235-
}),
236227
}
237228
}
238229
}
@@ -500,20 +491,3 @@ impl SetEnv {
500491
format!("setenv {} \"{}\"", self.set, self.value)
501492
}
502493
}
503-
504-
/// Stores the error message of the unrecognized key
505-
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
506-
pub struct UnrecognizedKey {
507-
pub error: String,
508-
}
509-
510-
impl UnrecognizedKey {
511-
/// Empty bash source
512-
pub fn bash_source(&self) -> String {
513-
String::from("")
514-
}
515-
/// Empty tcsh source
516-
pub fn tcsh_source(&self) -> String {
517-
String::from("")
518-
}
519-
}

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use spk_schema_foundation::ident_build::BuildId;
1313
use spk_schema_foundation::ident_component::ComponentBTreeSet;
1414
use spk_schema_foundation::name::PkgNameBuf;
1515
use spk_schema_foundation::option_map::Stringified;
16-
use spk_schema_ident::{AnyIdent, BuildIdent, Ident, VersionIdent};
16+
use spk_schema_ident::{AnyIdent, BuildIdent, Ident, RangeIdent, VersionIdent};
1717
use struct_field_names_as_array::FieldNamesAsArray;
1818

1919
use super::variant_spec::VariantSpecEntryKey;
@@ -905,7 +905,7 @@ impl<B, T> SpecVisitor<B, T> {
905905
build: None,
906906
tests: None,
907907
install: None,
908-
lints: None,
908+
lints: Vec::default(),
909909
check_build_spec,
910910
}
911911
}
@@ -978,6 +978,13 @@ impl<B, T> Lints for SpecVisitor<B, T> {
978978
}
979979
}
980980

981+
impl<B, T> Default for SpecVisitor<B, T> {
982+
#[inline]
983+
fn default() -> Self {
984+
Self::with_check_build_spec(true)
985+
}
986+
}
987+
981988
impl SpecVisitor<PkgNameBuf, Version> {
982989
pub fn recipe() -> Self {
983990
Self::default()

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl crate::Test for TestSpec {
3939
struct TestSpecVisitor {
4040
stage: Option<TestStage>,
4141
script: Option<Script>,
42-
selectors: Vec<OptionMap>,
42+
selectors: Vec<super::VariantSpec>,
4343
requirements: Vec<Request>,
4444
#[field_names_as_array(skip)]
4545
lints: Vec<Lint>,
@@ -99,7 +99,7 @@ impl<'de> serde::de::Visitor<'de> for TestSpecVisitor {
9999
match key.as_str() {
100100
"stage" => self.stage = Some(map.next_value::<TestStage>()?),
101101
"script" => self.script = Some(map.next_value::<Script>()?),
102-
"selectors" => self.selectors = map.next_value::<Vec<OptionMap>>()?,
102+
"selectors" => self.selectors = map.next_value::<Vec<super::VariantSpec>>()?,
103103
"requirements" => self.requirements = map.next_value::<Vec<Request>>()?,
104104
unknown_key => {
105105
self.lints.push(Lint::Key(UnknownKey::new(

0 commit comments

Comments
 (0)