m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-17 17:43:37 -05:00

Show unknown when image tag does not exist

This commit is contained in:
Sergio
2025-01-15 17:09:19 +02:00
parent 3ac6fb57e9
commit 4bbb53cd67
2 changed files with 13 additions and 8 deletions

View File

@@ -103,7 +103,6 @@ impl Image {
}
}
/// Compares remote digest of the image with its local digests to determine if it has an update or not
pub fn has_update(&self) -> Status {
if self.error.is_some() {
Status::Unknown(self.error.clone().unwrap())
@@ -190,7 +189,7 @@ impl Image {
},
time: self.time_ms,
server: None,
status: Status::Unknown(String::new()),
status: has_update,
}
}

View File

@@ -78,23 +78,29 @@ impl Version {
}
pub fn to_status(&self, base: &Self) -> Status {
if self.major == base.major {
if self.major > base.major {
Status::UpdateMajor
} else if self.major == base.major {
match (self.minor, base.minor) {
(Some(a_minor), Some(b_minor)) => {
if a_minor == b_minor {
if a_minor > b_minor {
Status::UpdateMinor
} else if a_minor == b_minor {
match (self.patch, base.patch) {
(Some(a_patch), Some(b_patch)) => {
if a_patch == b_patch {
if a_patch > b_patch {
Status::UpdatePatch
} else if a_patch == b_patch {
Status::UpToDate
} else {
Status::UpdatePatch
Status::Unknown(format!("Tag {} does not exist", base))
}
}
(None, None) => Status::UpToDate,
_ => unreachable!(),
}
} else {
Status::UpdateMinor
Status::Unknown(format!("Tag {} does not exist", base))
}
}
(None, None) => Status::UpToDate,
@@ -104,7 +110,7 @@ impl Version {
),
}
} else {
Status::UpdateMajor
Status::Unknown(format!("Tag {} does not exist", base))
}
}
}