Skip to content

Commit

Permalink
fix: bug with aliasing core tools (#3395)
Browse files Browse the repository at this point in the history
Fixes #3324
  • Loading branch information
jdx authored Dec 7, 2024
1 parent 3e5461d commit af1bee0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions e2e/config/test_config_alias
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
cat <<EOF >mise.toml
tools.erlang = "1.0.0-erlang"
tools.node = "1.0.0-node"
tools.corenode = "22.0.0"
tools.python = "1.0.0-python"
tools.mytool = "2"
tools.mytool-lts = "lts"
[alias]
erlang = 'asdf:https://github.com/jdx/mise-tiny'
node = "asdf:tiny"
corenode = "core:node"
python = 'asdf:jdx/mise-tiny'
mytool = "asdf:tiny"
[alias.mytool-lts]
Expand All @@ -19,6 +21,7 @@ EOF

assert_contains "mise x erlang -- mise-tiny" "mise-tiny: v1.0.0-erlang"
assert_contains "mise x node -- rtx-tiny" "rtx-tiny: v1.0.0-node"
assert_contains "mise x corenode -- node -v" "v22.0.0"
assert_contains "mise x python -- mise-tiny" "mise-tiny: v1.0.0-python"
assert_contains "mise x mytool -- rtx-tiny" "rtx-tiny: v2.1.0"
assert_contains "mise x mytool-lts -- rtx-tiny" "rtx-tiny: v1.0.1"
Expand Down
12 changes: 11 additions & 1 deletion src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,17 @@ pub fn remove(short: &str) {

pub fn arg_to_backend(ba: BackendArg) -> Option<ABackend> {
match ba.backend_type() {
BackendType::Core => CORE_PLUGINS.get(&ba.short).cloned(),
BackendType::Core => {
CORE_PLUGINS
.get(&ba.short)
.or_else(|| {
// this can happen if something like "corenode" is aliased to "core:node"
ba.full()
.strip_prefix("core:")
.and_then(|short| CORE_PLUGINS.get(short))
})
.cloned()
}
BackendType::Aqua => Some(Arc::new(aqua::AquaBackend::from_arg(ba))),
BackendType::Asdf => Some(Arc::new(asdf::AsdfBackend::from_arg(ba))),
BackendType::Cargo => Some(Arc::new(cargo::CargoBackend::from_arg(ba))),
Expand Down

0 comments on commit af1bee0

Please sign in to comment.