diff --git a/src/db.rs b/src/db.rs index c5f3166..a71f29e 100644 --- a/src/db.rs +++ b/src/db.rs @@ -98,6 +98,7 @@ impl Connection { if SystemTime::now().duration_since(cache.from)? > CACHE_EXPIRE { Ok(None) } else { + debug!("{package} {:?}", cache.info); Ok(Some(cache.info)) } } @@ -196,6 +197,7 @@ impl Connection { if is_compatible(debversion, &version)? { info.version = debversion.to_string(); info.status = PkgStatus::Found; + debug!("{package} {:?}", info); return Ok(info); } else if is_compatible(debversion, &semver_version)? { info.version = debversion.to_string(); @@ -206,6 +208,7 @@ impl Connection { } } + debug!("{package} {:?}", info); Ok(info) } } @@ -261,4 +264,26 @@ mod tests { .unwrap(); assert_eq!(info.status, PkgStatus::NotFound); } + + #[test] + #[ignore] + fn check_zerover_version_reqs() { + let mut db = Connection::new().unwrap(); + // Debian bookworm has rust-zoxide v0.4.3 and shouldn't be updated anymore + let query = + "SELECT version::text FROM sources WHERE source in ($1, $2) AND release='bookworm';"; + let info = db + .search_generic(query, "zoxide", &Version::parse("0.4.1").unwrap()) + .unwrap(); + assert_eq!(info.status, PkgStatus::Found); + assert_eq!(info.version, "0.4.3"); + let info = db + .search_generic(query, "zoxide", &Version::parse("0.4.5").unwrap()) + .unwrap(); + assert_eq!(info.status, PkgStatus::Compatible); + let info = db + .search_generic(query, "zoxide", &Version::parse("0.5.0").unwrap()) + .unwrap(); + assert_eq!(info.status, PkgStatus::Outdated); + } } diff --git a/src/debian.rs b/src/debian.rs index 46b8703..1bec3e3 100644 --- a/src/debian.rs +++ b/src/debian.rs @@ -45,6 +45,18 @@ impl Pkg { false } } + + pub fn show_dependencies(&self) -> bool { + if !self.in_debian() { + return true; + } + + if let Some(deb) = &self.debinfo { + !deb.exact_match && (deb.outdated || !deb.compatible) + } else { + true + } + } } #[derive(Debug, Clone)] @@ -53,6 +65,7 @@ pub struct DebianInfo { pub in_new: bool, pub outdated: bool, pub compatible: bool, + pub exact_match: bool, pub version: String, } @@ -62,6 +75,7 @@ fn run_task(db: &mut Connection, pkg: Pkg) -> Result { in_new: false, outdated: false, compatible: false, + exact_match: false, version: String::new(), }; @@ -80,6 +94,7 @@ fn run_task(db: &mut Connection, pkg: Pkg) -> Result { match info.status { PkgStatus::Outdated => deb.outdated = true, PkgStatus::Compatible => deb.compatible = true, + PkgStatus::Found => deb.exact_match = true, _ => (), } diff --git a/src/format/mod.rs b/src/format/mod.rs index 103d5ee..730ece0 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -65,6 +65,13 @@ impl<'a> fmt::Display for Display<'a> { pkg.green(), deb.version.yellow() )?; + } else if deb.outdated { + write!( + fmt, + "{} (outdated, {} in debian)", + pkg.yellow(), + deb.version.red() + )?; } else { write!(fmt, "{} (in debian)", pkg.green())?; } @@ -76,11 +83,18 @@ impl<'a> fmt::Display for Display<'a> { pkg.blue(), deb.version.yellow() )?; + } else if deb.outdated { + write!( + fmt, + "{}, (outdated, {} in debian NEW queue)", + pkg.blue(), + deb.version.red() + )?; } else { write!(fmt, "{} (in debian NEW queue)", pkg.blue())?; } } else if deb.outdated { - write!(fmt, "{} (outdated, {})", pkg.red(), deb.version)?; + write!(fmt, "{} (outdated, {})", pkg.red(), deb.version.red())?; } else { write!(fmt, "{pkg}")?; } diff --git a/src/tree.rs b/src/tree.rs index 15ec2b9..0b98677 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -208,7 +208,7 @@ fn print_package<'a>( println!("{}", format.display(package)); - if package.in_debian() { + if !all && !package.show_dependencies() { return; }