fix the version parsing and improve error handling

This commit is contained in:
Tamo 2024-10-29 02:51:26 +01:00
parent ddd03e9b37
commit a9b61c8434

View File

@ -41,8 +41,11 @@ impl OfflineUpgrade {
let (target_major, target_minor, target_patch) = &self.target_version; let (target_major, target_minor, target_patch) = &self.target_version;
let ends_at = match (target_major.as_str(), target_minor.as_str(), target_patch.as_str()) { let ends_at = match (target_major.as_str(), target_minor.as_str(), target_patch.as_str()) {
("v1", "10", _) => 0, ("1", "10", _) => 0,
("v1", "11", _) => 1, ("1", "11", _) => 1,
(major, _, _) if major.starts_with('v') => {
bail!("Target version must not starts with a `v`. Instead of writing `v1.9.0` write `1.9.0` for example.")
}
_ => { _ => {
bail!("Unsupported target version {target_major}.{target_minor}.{target_patch}. Can only upgrade to v1.11") bail!("Unsupported target version {target_major}.{target_minor}.{target_patch}. Can only upgrade to v1.11")
} }