Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use same outdated logic for mise ls as mise outdated #2737

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::install_context::InstallContext;
use crate::plugins::core::{CorePlugin, CORE_PLUGINS};
use crate::plugins::{Plugin, PluginType, VERSION_REGEX};
use crate::runtime_symlinks::is_runtime_symlink;
use crate::toolset::{ToolRequest, ToolVersion, Toolset};
use crate::toolset::{is_outdated_version, ToolRequest, ToolVersion, Toolset};
use crate::ui::progress_report::SingleReport;
use crate::{dirs, env, file, lock_file};

Expand Down Expand Up @@ -255,7 +255,7 @@ pub trait Backend: Debug + Send + Sync {
return false;
}
};
!self.is_version_installed(tv, true) || tv.version != latest
!self.is_version_installed(tv, true) || is_outdated_version(&tv.version, &latest)
}
fn symlink_path(&self, tv: &ToolVersion) -> Option<PathBuf> {
match tv.install_path() {
Expand Down
15 changes: 9 additions & 6 deletions src/toolset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,18 @@ fn get_leaf_dependencies(requests: &[ToolRequest]) -> eyre::Result<Vec<&ToolRequ
Ok(leaves)
}

fn is_outdated_version(current: &str, latest: &str) -> bool {
let c = Version::new(current);
let l = Version::new(latest);
if c.is_some() && l.is_some() {
return c.lt(&l);
pub fn is_outdated_version(current: &str, latest: &str) -> bool {
if let (Some(c), Some(l)) = (Version::new(current), Version::new(latest)) {
c.lt(&l)
} else {
current != latest
}
current != latest
}

/// check if the new version is a bump from the old version and return the new version
/// at the same specifity level as the old version
/// used with `mise outdated --bump` to determine what new semver range to use
/// given old: "20" and new: "21.2.3", return Some("21")
fn check_semver_bump(old: &str, new: &str) -> Option<String> {
let old = Versioning::new(old);
let new = Versioning::new(new);
Expand Down
Loading