Skip to content

Commit

Permalink
compare library versions
Browse files Browse the repository at this point in the history
  • Loading branch information
blarfoon committed Nov 2, 2024
1 parent 3b9d389 commit 136ab12
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
21 changes: 11 additions & 10 deletions daedalus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
reqwest = { version = "0", default-features = false, features = [
reqwest = { version = "0.12.9", default-features = false, features = [
"json",
"rustls-tls",
] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
chrono = { version = "0", features = ["serde"] }
backon = "1"
bytes = "1"
thiserror = "1"
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
chrono = { version = "0.4.38", features = ["serde"] }
backon = "1.2.0"
bytes = "1.8.0"
thiserror = "1.0.66"
tokio = { version = "1.41.0", features = ["full"] }
sha1 = { version = "0.6.1", features = ["std"] }
bincode = { version = "2.0.0-rc.3", features = ["serde"], optional = true }
once_cell = "1"
url = "2"
once_cell = "1.20.2"
url = "2.5.2"
lenient_semver = { version = "0.4.2" }

[build-dependencies]
dotenvy = "0.15.6"
21 changes: 20 additions & 1 deletion daedalus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#![warn(missing_docs, unused_import_braces, missing_debug_implementations)]

use std::{
convert::TryFrom, fmt::Display, path::PathBuf, str::FromStr, time::Duration,
cmp::Ordering, convert::TryFrom, fmt::Display, path::PathBuf, str::FromStr,
time::Duration,
};

use backon::{ExponentialBuilder, Retryable};
Expand Down Expand Up @@ -178,6 +179,24 @@ impl GradleSpecifier {
pub fn is_log4j(&self) -> bool {
self.package.as_str() == "org.apache.logging.log4j"
}

/// Compares two versions
/// Returns Ordering::Equal if they are equal
/// Returns Ordering::Greater if self is greater than other
/// Returns Ordering::Less if self is less than other
pub fn compare_versions(&self, other: &Self) -> Result<Ordering, Error> {
let x = lenient_semver::parse(self.version.as_str());
let y = lenient_semver::parse(other.version.as_str());

if x.is_err() || y.is_err() {
return Err(Error::ParseError(
"Unable to parse version".to_string(),
));
}

// safe to unwrap because we already checked for errors
Ok(x.unwrap().cmp(&y.unwrap()))
}
}

impl FromStr for GradleSpecifier {
Expand Down
4 changes: 2 additions & 2 deletions daedalus_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
lazy_static = "1.4.0"
anyhow = "1.0"
reqwest = { version = "0.11.13", default-features = false, features = [
reqwest = { version = "0.12.9", default-features = false, features = [
"json",
"rustls-tls",
] }
Expand All @@ -35,7 +35,7 @@ path-slash = "0.2.1"
sentry = "0.32.1"

[features]
default = ["sentry", "forge", "fabric", "quilt", "neoforge"]
default = ["forge", "fabric", "quilt", "neoforge"]
sentry = []
forge = []
fabric = []
Expand Down

0 comments on commit 136ab12

Please sign in to comment.