fix: Use lenient_semver for build drivers version check to handle pre-release versions
This commit is contained in:
parent
e88c7561a9
commit
003e473de1
11 changed files with 66 additions and 26 deletions
|
|
@ -16,6 +16,7 @@ constcat = "0.6"
|
|||
directories = "6"
|
||||
docker_credential = "1"
|
||||
format_serde_error = "0.3"
|
||||
lenient_semver = "0.4"
|
||||
process_control = { version = "4", features = ["crossbeam-channel"] }
|
||||
which = "7"
|
||||
|
||||
|
|
@ -24,6 +25,7 @@ clap = { workspace = true, features = ["derive", "env"] }
|
|||
comlexr.workspace = true
|
||||
log.workspace = true
|
||||
miette.workspace = true
|
||||
semver.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde_yaml.workspace = true
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ pub mod command_output;
|
|||
pub mod constants;
|
||||
pub mod credentials;
|
||||
mod macros;
|
||||
pub mod semver;
|
||||
pub mod syntax_highlighting;
|
||||
#[cfg(feature = "test")]
|
||||
pub mod test_utils;
|
||||
|
|
|
|||
31
utils/src/semver.rs
Normal file
31
utils/src/semver.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use serde::{de::Error, Deserialize};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Version(semver::Version);
|
||||
|
||||
impl std::ops::Deref for Version {
|
||||
type Target = semver::Version;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Version {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for Version {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let ver = String::deserialize(deserializer)?;
|
||||
lenient_semver::parse(&ver)
|
||||
.ok()
|
||||
.map(Self)
|
||||
.ok_or_else(|| D::Error::custom(format!("Failed to deserialize version {ver}")))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue