From b5aa0309ee7594d20c3847917046714b0a6518a4 Mon Sep 17 00:00:00 2001 From: Sergio <77530549+sergi0g@users.noreply.github.com> Date: Sat, 1 Feb 2025 10:28:17 +0200 Subject: [PATCH] Tiny improvement to version handling, add a new debug log --- src/registry.rs | 5 ++++- src/structs/version.rs | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/registry.rs b/src/registry.rs index 96346d8..c655602 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -182,7 +182,10 @@ pub async fn get_latest_tag( Some(t) => { if t == base && image.digest_info.is_some() { // Tags are equal so we'll compare digests - debug!(config.debug, "Tags for {} are equal, comparing digests.", image.reference); + debug!( + config.debug, + "Tags for {} are equal, comparing digests.", image.reference + ); get_latest_digest( &Image { version_info: Some(VersionInfo { diff --git a/src/structs/version.rs b/src/structs/version.rs index 92b6b1e..82cc57c 100644 --- a/src/structs/version.rs +++ b/src/structs/version.rs @@ -47,17 +47,20 @@ impl Version { let major: u32 = match c.name("major") { Some(major) => { positions.push((major.start(), major.end())); - major.as_str().parse().unwrap() + match major.as_str().parse() { + Ok(m) => m, + Err(_) => return None + } } None => return None, }; let minor: Option = c.name("minor").map(|minor| { positions.push((minor.start(), minor.end())); - minor.as_str().parse().unwrap() + minor.as_str().parse().expect(&format!("Minor version invalid in tag {}", tag)) }); let patch: Option = c.name("patch").map(|patch| { positions.push((patch.start(), patch.end())); - patch.as_str().parse().unwrap() + patch.as_str().parse().expect(&format!("Patch version invalid in tag {}", tag)) }); let mut format_str = tag.to_string(); positions.reverse();