Skip to content

Commit

Permalink
fix: disallow dash in version (#1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Sep 24, 2024
1 parent f2da23d commit 07fc8d8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/recipe/custom_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,17 @@ impl TryConvertNode<VersionWithSource> for RenderedNode {

impl TryConvertNode<VersionWithSource> for RenderedScalarNode {
fn try_convert(&self, name: &str) -> Result<VersionWithSource, Vec<PartialParsingError>> {
let s = self.as_str();
if s.contains('-') {
// version is not allowed to contain a `-`
return Err(vec![_partialerror!(
*self.span(),
ErrorKind::InvalidValue((name.to_string(), "version cannot contain `-`".into())),
label = format!("version `{s}` cannot contain `-` "),
help = "replace the `-` with `_` or remove it"
)]);
}

VersionWithSource::from_str(self.as_str())
.map_err(|err| {
_partialerror!(
Expand Down

0 comments on commit 07fc8d8

Please sign in to comment.