Skip to content

Commit 098e062

Browse files
author
Nichol Yip
committed
Fixed changes from rebase
Signed-off-by: Nichol Yip <[email protected]>
1 parent 93d4866 commit 098e062

File tree

4 files changed

+13
-31
lines changed

4 files changed

+13
-31
lines changed

crates/spk-schema/src/build_spec.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use strum::Display;
1818

1919
use super::{v0, Opt, ValidationSpec};
2020
use crate::name::{OptName, OptNameBuf};
21-
use crate::option::VarOpt;
22-
use crate::{Lint, LintedItem, Lints, Result, UnknownKey, Variant};
21+
use crate::option::{PkgOpt, VarOpt};
22+
use crate::{Error, Lint, LintedItem, Lints, Result, UnknownKey, Variant};
2323

2424
#[cfg(test)]
2525
#[path = "./build_spec_test.rs"]
@@ -406,6 +406,7 @@ impl<'de> Deserialize<'de> for BuildSpec {
406406
/// being deserialized must be trusted (eg it's from a repository)
407407
/// but may also not adhere to all of the (potentially new) validation
408408
/// that is done on the normal build spec
409+
#[derive(Default)]
409410
pub(crate) struct UncheckedBuildSpec(BuildSpec);
410411

411412
impl UncheckedBuildSpec {

crates/spk-schema/src/environ.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub enum OpKind {
3535
Prepend,
3636
Priority,
3737
Set,
38-
UnrecognizedKey,
3938
}
4039

4140
/// An operation performed to the environment
@@ -47,7 +46,6 @@ pub enum EnvOp {
4746
Prepend(PrependEnv),
4847
Priority(EnvPriority),
4948
Set(SetEnv),
50-
UnrecognizedKey(UnrecognizedKey),
5149
}
5250

5351
impl EnvOp {
@@ -58,7 +56,6 @@ impl EnvOp {
5856
EnvOp::Prepend(_) => OpKind::Prepend,
5957
EnvOp::Priority(_) => OpKind::Priority,
6058
EnvOp::Set(_) => OpKind::Set,
61-
EnvOp::UnrecognizedKey(_) => OpKind::UnrecognizedKey,
6259
}
6360
}
6461

@@ -69,7 +66,6 @@ impl EnvOp {
6966
EnvOp::Prepend(_) => "",
7067
EnvOp::Priority(_) => "",
7168
EnvOp::Set(_) => "",
72-
EnvOp::UnrecognizedKey(e) => e.error.as_str(),
7369
}
7470
}
7571

@@ -147,7 +143,6 @@ impl EnvOp {
147143
Self::Prepend(op) => op.bash_source(),
148144
Self::Priority(op) => op.bash_source(),
149145
Self::Set(op) => op.bash_source(),
150-
Self::UnrecognizedKey(op) => op.bash_source(),
151146
}
152147
}
153148

@@ -159,7 +154,6 @@ impl EnvOp {
159154
Self::Prepend(op) => op.tcsh_source(),
160155
Self::Priority(op) => op.tcsh_source(),
161156
Self::Set(op) => op.tcsh_source(),
162-
Self::UnrecognizedKey(op) => op.tcsh_source(),
163157
}
164158
}
165159

@@ -231,9 +225,6 @@ impl From<EnvOpVisitor> for EnvOp {
231225
OpKind::Priority => EnvOp::Priority(EnvPriority {
232226
priority: var.get_priority(),
233227
}),
234-
OpKind::UnrecognizedKey => EnvOp::UnrecognizedKey(UnrecognizedKey {
235-
error: var.get_op(),
236-
}),
237228
}
238229
}
239230
}
@@ -526,20 +517,3 @@ impl SetEnv {
526517
format!("setenv {} \"{}\"", self.set, self.value)
527518
}
528519
}
529-
530-
/// Stores the error message of the unrecognized key
531-
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
532-
pub struct UnrecognizedKey {
533-
pub error: String,
534-
}
535-
536-
impl UnrecognizedKey {
537-
/// Empty bash source
538-
pub fn bash_source(&self) -> String {
539-
String::from("")
540-
}
541-
/// Empty tcsh source
542-
pub fn tcsh_source(&self) -> String {
543-
String::from("")
544-
}
545-
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ impl<B, T> SpecVisitor<B, T> {
995995
build: None,
996996
tests: None,
997997
install: None,
998-
lints: None,
998+
lints: Vec::default(),
999999
check_build_spec,
10001000
}
10011001
}
@@ -1068,6 +1068,13 @@ impl<B, T> Lints for SpecVisitor<B, T> {
10681068
}
10691069
}
10701070

1071+
impl<B, T> Default for SpecVisitor<B, T> {
1072+
#[inline]
1073+
fn default() -> Self {
1074+
Self::with_check_build_spec(true)
1075+
}
1076+
}
1077+
10711078
impl SpecVisitor<PkgNameBuf, Version> {
10721079
pub fn recipe() -> Self {
10731080
Self::default()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl crate::Test for TestSpec {
4040
struct TestSpecVisitor {
4141
stage: Option<TestStage>,
4242
script: Option<Script>,
43-
selectors: Vec<OptionMap>,
43+
selectors: Vec<super::VariantSpec>,
4444
requirements: Vec<Request>,
4545
#[field_names_as_array(skip)]
4646
lints: Vec<Lint>,
@@ -100,7 +100,7 @@ impl<'de> serde::de::Visitor<'de> for TestSpecVisitor {
100100
match key.as_str() {
101101
"stage" => self.stage = Some(map.next_value::<TestStage>()?),
102102
"script" => self.script = Some(map.next_value::<Script>()?),
103-
"selectors" => self.selectors = map.next_value::<Vec<OptionMap>>()?,
103+
"selectors" => self.selectors = map.next_value::<Vec<super::VariantSpec>>()?,
104104
"requirements" => self.requirements = map.next_value::<Vec<Request>>()?,
105105
unknown_key => {
106106
self.lints.push(Lint::Key(UnknownKey::new(

0 commit comments

Comments
 (0)