-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Sorry if this issue is moot, but the following block seems to pick compatible updates first.
Lines 178 to 217 in 196ca00
| let releases = self.get_latest_releases(¤t_version)?; | |
| let release = { | |
| // Filter compatible version | |
| let compatible_releases = releases | |
| .iter() | |
| .filter(|r| { | |
| version::bump_is_compatible(¤t_version, &r.version) | |
| .unwrap_or(false) | |
| }) | |
| .collect::<Vec<_>>(); | |
| // Get the first version | |
| let release = compatible_releases.first().cloned(); | |
| if let Some(release) = release { | |
| println( | |
| show_output, | |
| &format!( | |
| "v{} ({} versions compatible)", | |
| release.version, | |
| compatible_releases.len() | |
| ), | |
| ); | |
| release.clone() | |
| } else { | |
| let release = releases.first(); | |
| if let Some(release) = release { | |
| println( | |
| show_output, | |
| &format!( | |
| "v{} ({} versions available)", | |
| release.version, | |
| releases.len() | |
| ), | |
| ); | |
| release.clone() | |
| } else { | |
| return Ok(UpdateStatus::UpToDate); | |
| } | |
| } | |
| }; |
Given the following releases: 1.1.0, 1.1.1, 1.1.2, 2.0.0 and a client running 1.1.1, self_update will first upgrade to 1.1.2 and only then upgrade to 2.0.0. Updating to latest version would take two separate invocations.
Such behaviour may be desired in some cases, but is extremely counter-intuitive IMO. So far I have to get_latest_release, get its tag and then use Update pinned to that tag explicitly. However, that does more network requests than necessary, and supporting "always latest" strategy should be trivial in code above.
I understand this would be a breaking change, so probably a builder flag (like .always_latest(true)) is the safest solution. Alternatively, it might be a good idea to introduce an UpgradeStrategy enum to support "always latest", "prefer compatible", "only compatible" strategies.
I'm ready to contribute a PR with this change.