From 120a7cdf2cee6d6089233d8e2748028f2411c96b Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdx@users.noreply.github.com> Date: Thu, 14 Dec 2023 04:26:00 -0600 Subject: [PATCH] poetry --- justfile | 4 ++-- src/cli/install.rs | 6 +----- src/shims.rs | 11 +++-------- src/toolset/mod.rs | 20 ++++++-------------- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/justfile b/justfile index 96649fe967..5ae0dbac6e 100644 --- a/justfile +++ b/justfile @@ -59,11 +59,11 @@ test-coverage: echo "::group::Build w/ coverage" cargo build --all-features - echo "::group::Unit tests" - cargo test --all-features echo "::endgroup::" ./e2e/run_all_tests if [[ "${TEST_TRANCHE:-}" == 0 ]]; then + echo "::group::Unit tests" + cargo test --all-features echo "::group::Trust" rtx trust echo "::group::render-help render-completions render-mangen" diff --git a/src/cli/install.rs b/src/cli/install.rs index e5db33a7e3..4b9f3b0d17 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -120,11 +120,7 @@ impl Install { fn install_missing_runtimes(&self, config: &Config) -> Result<()> { let mut ts = ToolsetBuilder::new().with_latest_versions().build(config)?; - let versions = ts - .list_missing_versions(config) - .into_iter() - .cloned() - .collect::>(); + let versions = ts.list_missing_versions(); if versions.is_empty() { info!("all runtimes are installed"); return Ok(()); diff --git a/src/shims.rs b/src/shims.rs index ab98a55fe0..c5fc75be51 100644 --- a/src/shims.rs +++ b/src/shims.rs @@ -64,7 +64,7 @@ fn which_shim(config: &Config, bin_name: &str) -> Result { } } let tvs = ts.list_rtvs_with_bin(config, bin_name)?; - err_no_version_set(config, ts, bin_name, tvs)?; + err_no_version_set(ts, bin_name, tvs)?; } Err(eyre!("{} is not a valid shim", bin_name)) } @@ -190,18 +190,13 @@ fn make_shim(target: &Path, shim: &Path) -> Result<()> { Ok(()) } -fn err_no_version_set( - config: &Config, - ts: Toolset, - bin_name: &str, - tvs: Vec, -) -> Result<()> { +fn err_no_version_set(ts: Toolset, bin_name: &str, tvs: Vec) -> Result<()> { if tvs.is_empty() { return Ok(()); } let missing_plugins = tvs.iter().map(|tv| &tv.plugin_name).collect::>(); let mut missing_tools = ts - .list_missing_versions(config) + .list_missing_versions() .into_iter() .filter(|t| missing_plugins.contains(&t.plugin_name)) .collect_vec(); diff --git a/src/toolset/mod.rs b/src/toolset/mod.rs index 24ac224d8e..61f21ac188 100644 --- a/src/toolset/mod.rs +++ b/src/toolset/mod.rs @@ -95,7 +95,7 @@ impl Toolset { let versions = self .list_current_versions() .into_iter() - .filter(|(p, tv)| opts.force || p.is_version_installed(tv)) + .filter(|(p, tv)| opts.force || !p.is_version_installed(tv)) .map(|(_, tv)| tv) .filter(|tv| matches!(self.versions[&tv.plugin_name].source, ToolSource::Argument)) .collect_vec(); @@ -172,19 +172,11 @@ impl Toolset { shims::reshim(config, self)?; runtime_symlinks::rebuild(config) } - pub fn list_missing_versions(&self, config: &Config) -> Vec<&ToolVersion> { - self.versions - .iter() - .map(|(p, tvl)| { - let p = config.get_or_create_plugin(p); - (p, tvl) - }) - .flat_map(|(p, tvl)| { - tvl.versions - .iter() - .filter(|tv| !p.is_version_installed(tv)) - .collect_vec() - }) + pub fn list_missing_versions(&self) -> Vec { + self.list_current_versions() + .into_iter() + .filter(|(p, tv)| !p.is_version_installed(tv)) + .map(|(_, tv)| tv) .collect() } pub fn list_installed_versions(