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
4 changes: 4 additions & 0 deletions e2e/backend/test_bare_backend_names
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

assert_fail "mise install cargo" "cargo not found in mise tool registry"
assert_fail "mise install gem" "gem not found in mise tool registry"
26 changes: 24 additions & 2 deletions src/cli/args/backend_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@ impl BackendArg {
}

let full = self.full();
let backend = full.split(':').next().unwrap();
if let Ok(backend_type) = backend.parse() {
if let Some((backend, _)) = full.split_once(':')
&& let Ok(backend_type) = backend.parse()
{
return backend_type;
}
if config::is_loaded() && Config::get_().get_repo_url(&self.short).is_some() {
Expand Down Expand Up @@ -648,6 +649,27 @@ mod tests {
);
}

#[tokio::test]
async fn test_bare_package_backend_names_are_not_implicit_tools() {
let _config = Config::get().await.unwrap();

for name in ["cargo", "gem"] {
let fa: BackendArg = name.into();
assert_str_eq!(name, fa.full());
assert_eq!(BackendType::Unknown, fa.backend_type());
}

let fa: BackendArg = "cargo:ripgrep".into();
assert_eq!(BackendType::Cargo, fa.backend_type());

let fa: BackendArg = "gem:bashly".into();
assert_eq!(BackendType::Gem, fa.backend_type());

let fa: BackendArg = "npm".into();
assert_str_eq!("npm:npm", fa.full());
assert_eq!(BackendType::Npm, fa.backend_type());
}

#[tokio::test]
async fn test_backend_arg_pathname() {
let _config = Config::get().await.unwrap();
Expand Down
5 changes: 4 additions & 1 deletion src/toolset/install_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,10 @@ pub fn backend_type(short: &str) -> Result<Option<BackendType>> {
let backend_type = list_tools()
.get(short)
.and_then(|ist| ist.full.as_ref())
.map(|full| BackendType::guess(full));
.and_then(|full| {
full.split_once(':')
.map(|(backend, _)| BackendType::guess(backend))
});
if let Some(BackendType::Unknown) = backend_type
&& let Some((plugin_name, _)) = short.split_once(':')
&& let Some(PluginType::VfoxBackend) = get_plugin_type(plugin_name)
Expand Down
Loading