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
|
|
@ -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