Skip to content

Commit

Permalink
Fixed changes from rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Nichol Yip <nyip@imageworks.com>
  • Loading branch information
Nichol Yip committed Aug 26, 2024
1 parent 93d4866 commit 098e062
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 31 deletions.
5 changes: 3 additions & 2 deletions crates/spk-schema/src/build_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use strum::Display;

use super::{v0, Opt, ValidationSpec};
use crate::name::{OptName, OptNameBuf};
use crate::option::VarOpt;
use crate::{Lint, LintedItem, Lints, Result, UnknownKey, Variant};
use crate::option::{PkgOpt, VarOpt};
use crate::{Error, Lint, LintedItem, Lints, Result, UnknownKey, Variant};

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

impl UncheckedBuildSpec {
Expand Down
26 changes: 0 additions & 26 deletions crates/spk-schema/src/environ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub enum OpKind {
Prepend,
Priority,
Set,
UnrecognizedKey,
}

/// An operation performed to the environment
Expand All @@ -47,7 +46,6 @@ pub enum EnvOp {
Prepend(PrependEnv),
Priority(EnvPriority),
Set(SetEnv),
UnrecognizedKey(UnrecognizedKey),
}

impl EnvOp {
Expand All @@ -58,7 +56,6 @@ impl EnvOp {
EnvOp::Prepend(_) => OpKind::Prepend,
EnvOp::Priority(_) => OpKind::Priority,
EnvOp::Set(_) => OpKind::Set,
EnvOp::UnrecognizedKey(_) => OpKind::UnrecognizedKey,
}
}

Expand All @@ -69,7 +66,6 @@ impl EnvOp {
EnvOp::Prepend(_) => "",
EnvOp::Priority(_) => "",
EnvOp::Set(_) => "",
EnvOp::UnrecognizedKey(e) => e.error.as_str(),
}
}

Expand Down Expand Up @@ -147,7 +143,6 @@ impl EnvOp {
Self::Prepend(op) => op.bash_source(),
Self::Priority(op) => op.bash_source(),
Self::Set(op) => op.bash_source(),
Self::UnrecognizedKey(op) => op.bash_source(),
}
}

Expand All @@ -159,7 +154,6 @@ impl EnvOp {
Self::Prepend(op) => op.tcsh_source(),
Self::Priority(op) => op.tcsh_source(),
Self::Set(op) => op.tcsh_source(),
Self::UnrecognizedKey(op) => op.tcsh_source(),
}
}

Expand Down Expand Up @@ -231,9 +225,6 @@ impl From<EnvOpVisitor> for EnvOp {
OpKind::Priority => EnvOp::Priority(EnvPriority {
priority: var.get_priority(),
}),
OpKind::UnrecognizedKey => EnvOp::UnrecognizedKey(UnrecognizedKey {
error: var.get_op(),
}),
}
}
}
Expand Down Expand Up @@ -526,20 +517,3 @@ impl SetEnv {
format!("setenv {} \"{}\"", self.set, self.value)
}
}

/// Stores the error message of the unrecognized key
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct UnrecognizedKey {
pub error: String,
}

impl UnrecognizedKey {
/// Empty bash source
pub fn bash_source(&self) -> String {
String::from("")
}
/// Empty tcsh source
pub fn tcsh_source(&self) -> String {
String::from("")
}
}
9 changes: 8 additions & 1 deletion crates/spk-schema/src/v0/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ impl<B, T> SpecVisitor<B, T> {
build: None,
tests: None,
install: None,
lints: None,
lints: Vec::default(),
check_build_spec,
}
}
Expand Down Expand Up @@ -1068,6 +1068,13 @@ impl<B, T> Lints for SpecVisitor<B, T> {
}
}

impl<B, T> Default for SpecVisitor<B, T> {
#[inline]
fn default() -> Self {
Self::with_check_build_spec(true)
}
}

impl SpecVisitor<PkgNameBuf, Version> {
pub fn recipe() -> Self {
Self::default()
Expand Down
4 changes: 2 additions & 2 deletions crates/spk-schema/src/v0/test_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl crate::Test for TestSpec {
struct TestSpecVisitor {
stage: Option<TestStage>,
script: Option<Script>,
selectors: Vec<OptionMap>,
selectors: Vec<super::VariantSpec>,
requirements: Vec<Request>,
#[field_names_as_array(skip)]
lints: Vec<Lint>,
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<'de> serde::de::Visitor<'de> for TestSpecVisitor {
match key.as_str() {
"stage" => self.stage = Some(map.next_value::<TestStage>()?),
"script" => self.script = Some(map.next_value::<Script>()?),
"selectors" => self.selectors = map.next_value::<Vec<OptionMap>>()?,
"selectors" => self.selectors = map.next_value::<Vec<super::VariantSpec>>()?,
"requirements" => self.requirements = map.next_value::<Vec<Request>>()?,
unknown_key => {
self.lints.push(Lint::Key(UnknownKey::new(
Expand Down

0 comments on commit 098e062

Please sign in to comment.