Skip to content

Commit

Permalink
poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 14, 2023
1 parent 00c0414 commit 120a7cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();
let versions = ts.list_missing_versions();
if versions.is_empty() {
info!("all runtimes are installed");
return Ok(());
Expand Down
11 changes: 3 additions & 8 deletions src/shims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn which_shim(config: &Config, bin_name: &str) -> Result<PathBuf> {
}
}
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)?;

Check warning on line 67 in src/shims.rs

View check run for this annotation

Codecov / codecov/patch

src/shims.rs#L67

Added line #L67 was not covered by tests
}
Err(eyre!("{} is not a valid shim", bin_name))
}
Expand Down Expand Up @@ -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<ToolVersion>,
) -> Result<()> {
fn err_no_version_set(ts: Toolset, bin_name: &str, tvs: Vec<ToolVersion>) -> Result<()> {

Check warning on line 193 in src/shims.rs

View check run for this annotation

Codecov / codecov/patch

src/shims.rs#L193

Added line #L193 was not covered by tests
if tvs.is_empty() {
return Ok(());
}
let missing_plugins = tvs.iter().map(|tv| &tv.plugin_name).collect::<HashSet<_>>();
let mut missing_tools = ts
.list_missing_versions(config)
.list_missing_versions()

Check warning on line 199 in src/shims.rs

View check run for this annotation

Codecov / codecov/patch

src/shims.rs#L199

Added line #L199 was not covered by tests
.into_iter()
.filter(|t| missing_plugins.contains(&t.plugin_name))
.collect_vec();
Expand Down
20 changes: 6 additions & 14 deletions src/toolset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<ToolVersion> {
self.list_current_versions()
.into_iter()
.filter(|(p, tv)| !p.is_version_installed(tv))
.map(|(_, tv)| tv)
.collect()
}
pub fn list_installed_versions(
Expand Down

0 comments on commit 120a7cd

Please sign in to comment.