From efb28a30e2a24f793020ba270bacfbaf7a0ce3cf Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Thu, 30 Mar 2023 10:59:02 -0400 Subject: [PATCH] Fix for dependency resolution - take into account release number --- src/db/mod.rs | 5 ++++- src/package/mod.rs | 4 +++- src/version/mod.rs | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/db/mod.rs b/src/db/mod.rs index 7bc8938..3db5222 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -60,7 +60,10 @@ impl Database { // Check if we've already pulled in an update from another repo, // and if so compare versions if let Some(other_update) = updates.get(&name) { - if remote_package.version > other_update.version { + if remote_package.version > other_update.version + || (remote_package.version == other_update.version + && remote_package.release > other_update.release) + { // The remote version is an update to the already // pulled in update, so swap it out let update = Update { diff --git a/src/package/mod.rs b/src/package/mod.rs index 215cb7e..dfdd00b 100644 --- a/src/package/mod.rs +++ b/src/package/mod.rs @@ -122,7 +122,9 @@ impl Package { /// Tests whether this package is an update for another pub fn is_upgrade(&self, other: &Self) -> bool { - self.name == other.name && self.version > other.version + self.name == other.name + && (self.version > other.version + || (self.version == other.version && self.release > other.release)) } } diff --git a/src/version/mod.rs b/src/version/mod.rs index d37217b..21b3fa6 100644 --- a/src/version/mod.rs +++ b/src/version/mod.rs @@ -137,10 +137,21 @@ impl PartialOrd for Version { }, ) => b.partial_cmp(&d), ( - Self::SemVer { major, minor, patch }, + Self::SemVer { + major, + minor, + patch, + }, Self::Rapid { major: a, minor: b }, - ) => SemVer { major: *major, minor: *minor, patch: *patch } - .partial_cmp(&Rapid { major: *a, minor: *b }), + ) => SemVer { + major: *major, + minor: *minor, + patch: *patch, + } + .partial_cmp(&Rapid { + major: *a, + minor: *b, + }), _ => None, } }