Skip to content
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
22 changes: 21 additions & 1 deletion src/args/backend_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ impl BackendArg {
.first()?
.to_string();
let current = self.full_without_opts();
(current != registry).then_some((current, registry))
(!same_backend_kind(&current, &registry)).then_some((current, registry))
}

/// [`Self::superseded_backend`], when it is a lock entry that keeps the
Expand Down Expand Up @@ -1029,6 +1029,15 @@ impl Hash for BackendArg {
}
}

/// Whether two backends use the same backend kind (`aqua`, `vfox`, `asdf`,
/// `github`, ...), ignoring the repository or package they name. A registry
/// entry that moves to another repo or org within a kind installs the same way,
/// so only a change of kind counts as a backend switch.
pub fn same_backend_kind(a: &str, b: &str) -> bool {
a == b
|| matches!((a.split_once(':'), b.split_once(':')), (Some((a, _)), Some((b, _))) if a == b)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -1347,3 +1356,14 @@ fn pypi_and_pipx_use_distinct_tool_identities() {
assert_eq!(BackendType::guess("pipx:black"), BackendType::Pipx);
assert_eq!(BackendType::guess("pypi:black"), BackendType::Pipx);
}

#[test]
fn same_backend_kind_ignores_the_repository() {
assert!(same_backend_kind(
"vfox:mise-plugins/vfox-lua",
"vfox:jdx/vfox-lua"
));
assert!(same_backend_kind("aqua:old/name", "aqua:new/other-name"));
assert!(!same_backend_kind("aqua:foo/bar", "github:foo/bar"));
assert!(!same_backend_kind("vfox:jdx/vfox-lua", "asdf:jdx/vfox-lua"));
}
2 changes: 1 addition & 1 deletion src/args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use backend_arg::{BackendArg, BackendResolution, split_bracketed_opts};
pub use backend_arg::{BackendArg, BackendResolution, same_backend_kind, split_bracketed_opts};
pub use env_var_arg::EnvVarArg;
pub use tool_arg::{ToolArg, ToolVersionType};
pub use truncate::TruncateOptions;
Expand Down
10 changes: 5 additions & 5 deletions src/cli/doctor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,11 +1232,11 @@ impl Doctor {
};
// The install state records one backend per tool, so versions installed
// on either side of a cutover cannot all match it. Only warn when none do.
let strip = |full: &str| full.split('[').next().unwrap_or(full).to_string();
if recommended
.iter()
.any(|full| strip(full) == stored_stripped)
{
// Only a change of backend kind counts; a repo or org rename within one does not.
if recommended.iter().any(|full| {
let stripped = full.split('[').next().unwrap_or(full);
crate::args::same_backend_kind(stripped, stored_stripped)
}) {
continue;
}
let Some(registry_full) = recommended.first() else {
Expand Down
Loading