Skip to content

Commit

Permalink
fix: issue with non-default backends not getting tool options (#3265)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jdx authored Nov 28, 2024
1 parent 9a953e0 commit fa2eb47
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
8 changes: 8 additions & 0 deletions e2e/backend/test_ubi
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
6 changes: 6 additions & 0 deletions mise.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/cli/args/backend_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand Down
8 changes: 4 additions & 4 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Result<Vec<_>>>()?
.into_iter()
.flatten()
.collect::<Vec<_>>();
let file_tasks = includes
Expand Down
9 changes: 9 additions & 0 deletions src/toolset/install_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ pub fn list_plugins() -> Result<BTreeMap<String, PluginType>> {
Ok(plugins.as_ref().unwrap().clone())
}

pub fn get_tool_full(short: &str) -> Result<Option<String>> {
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<Option<PluginType>> {
let plugins = init_plugins()?;
Ok(plugins.as_ref().unwrap().get(short).cloned())
Expand Down
4 changes: 2 additions & 2 deletions xtasks/lint-fix
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,3 +23,4 @@ imports_granularity = "Module"
EOF
cargo fmt --all
rm rustfmt.toml
cargo clippy --all-features --fix --allow-staged --allow-dirty -- -Dwarnings

0 comments on commit fa2eb47

Please sign in to comment.