From fa2eb47907a2e8ddcba16ae6973401adf8e8405a Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Thu, 28 Nov 2024 08:10:01 -0600 Subject: [PATCH] fix: issue with non-default backends not getting tool options (#3265) In the case where you had installed a tool with one backend and that backend changes, mise was not passing the registry tool options to the old backend. Fixes #3262 --- e2e/backend/test_ubi | 8 ++++++++ mise.lock | 6 ++++++ mise.toml | 1 + src/cli/args/backend_arg.rs | 2 ++ src/config/mod.rs | 8 ++++---- src/toolset/install_state.rs | 9 +++++++++ xtasks/lint-fix | 4 ++-- 7 files changed, 32 insertions(+), 6 deletions(-) diff --git a/e2e/backend/test_ubi b/e2e/backend/test_ubi index a39f079cb..71da6e557 100644 --- a/e2e/backend/test_ubi +++ b/e2e/backend/test_ubi @@ -15,3 +15,11 @@ assert "cat mise.toml" '[tools] "ubi:cilium/cilium-cli" = { version = "latest", exe = "cilium" }' MISE_USE_VERSIONS_HOST=0 assert_not_contains "mise ls-remote cargo-binstall" "binstalk" + +# the following tests that tool options from ubi are still retained even if the default backend changes to aqua +assert "MISE_DISABLE_BACKENDS=aqua mise use gh" +cat "$MISE_DATA_DIR/installs/gh/.mise.backend" +assert_contains "mise tool gh" "ubi:cli/cli[exe=gh]" +assert "mise i -f gh" +cat "$MISE_DATA_DIR/installs/gh/.mise.backend" +assert_contains "mise tool gh" "ubi:cli/cli[exe=gh]" diff --git a/mise.lock b/mise.lock index 49287d391..75e3c3181 100644 --- a/mise.lock +++ b/mise.lock @@ -65,6 +65,12 @@ version = "3.3.3" [tools."pipx:toml-sort"] version = "0.24.2" +[tools.pre-commit] +version = "4.0.1" + +[tools.pre-commit.checksums] +"pre-commit-4.0.1.pyz" = "sha256:f3e65c943795be7879e7ea2beda248321b6c8ae851dabc785522a432fb8ce003" + [tools.ripgrep] version = "14.1.1" diff --git a/mise.toml b/mise.toml index 7fca39a93..d966ae66f 100644 --- a/mise.toml +++ b/mise.toml @@ -18,6 +18,7 @@ cosign = "latest" "npm:markdownlint-cli" = "latest" "npm:prettier" = "3" "pipx:toml-sort" = "latest" +pre-commit = "latest" #"python" = { version = "latest", virtualenv = "{{env.HOME}}/.cache/venv" } "ripgrep" = "latest" "shellcheck" = "0.10" diff --git a/src/cli/args/backend_arg.rs b/src/cli/args/backend_arg.rs index d4f60d3dd..48a5e3103 100644 --- a/src/cli/args/backend_arg.rs +++ b/src/cli/args/backend_arg.rs @@ -142,6 +142,8 @@ impl BackendArg { } if let Some(full) = &self.full { full.clone() + } else if let Some(full) = install_state::get_tool_full(short).unwrap_or_default() { + full } else if let Some(pt) = install_state::get_plugin_type(short).unwrap_or_default() { match pt { PluginType::Asdf => format!("asdf:{short}"), diff --git a/src/config/mod.rs b/src/config/mod.rs index 01372775e..abe7ec257 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -344,11 +344,11 @@ impl Config { p.is_file() && p.extension().unwrap_or_default().to_string_lossy() == "toml" }) .map(|p| { - self.load_task_file(p).unwrap_or_else(|err| { - warn!("loading tasks in {}: {err}", display_path(p)); - vec![] - }) + self.load_task_file(p) + .wrap_err_with(|| format!("loading tasks in {}", display_path(p))) }) + .collect::>>()? + .into_iter() .flatten() .collect::>(); let file_tasks = includes diff --git a/src/toolset/install_state.rs b/src/toolset/install_state.rs index 9af190a18..041cc1edb 100644 --- a/src/toolset/install_state.rs +++ b/src/toolset/install_state.rs @@ -126,6 +126,15 @@ pub fn list_plugins() -> Result> { Ok(plugins.as_ref().unwrap().clone()) } +pub fn get_tool_full(short: &str) -> Result> { + let tools = init_tools()?; + Ok(tools + .as_ref() + .unwrap() + .get(short) + .and_then(|t| t.full.clone())) +} + pub fn get_plugin_type(short: &str) -> Result> { let plugins = init_plugins()?; Ok(plugins.as_ref().unwrap().get(short).cloned()) diff --git a/xtasks/lint-fix b/xtasks/lint-fix index 2f01365f9..2507572d4 100755 --- a/xtasks/lint-fix +++ b/xtasks/lint-fix @@ -1,13 +1,12 @@ #!/usr/bin/env bash #MISE alias=["format"] -#MISE wait_for=["build", "render:settings"] +#MISE wait_for=["render:settings"] set -euxo pipefail # Used for shellcheck which needs explicit args scripts=("$PWD"/scripts/*.sh "$PWD"/e2e/{test_,run_}* "$PWD"/e2e/*.sh) # Used for shfmt which will run only on files it can scripts_dirs=("$PWD"/scripts "$PWD"/e2e) -cargo clippy --all-features --fix --allow-staged --allow-dirty -- -Dwarnings shellcheck -x "${scripts[@]}" shfmt -w -i 2 -ci -bn "${scripts_dirs[@]}" # shellcheck disable=SC2046 @@ -24,3 +23,4 @@ imports_granularity = "Module" EOF cargo fmt --all rm rustfmt.toml +cargo clippy --all-features --fix --allow-staged --allow-dirty -- -Dwarnings