Skip to content

Commit

Permalink
avoid nesting, better error and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Arrowana committed Dec 18, 2024
1 parent fe883ea commit 7682dd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- lang: Require `zero` accounts to be unique ([#3409](https://github.com/coral-xyz/anchor/pull/3409)).
- lang: Deduplicate `zero` accounts against `init` accounts ([#3422](https://github.com/coral-xyz/anchor/pull/3422)).
- cli: Fix custom `provider.cluster` ([#3428](https://github.com/coral-xyz/anchor/pull/3428)).
- cli: Ignore non semver solana/agave releases to avoid panic ([#3432](https://github.com/coral-xyz/anchor/pull/3432)).

### Breaking

Expand Down
13 changes: 6 additions & 7 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ fn override_toolchain(cfg_override: &ConfigOverride) -> Result<RestoreToolchainC
}

let output_version = std::str::from_utf8(&output.stdout)?;
let version = parse_version(output_version).unwrap();
Ok(version)
parse_version(output_version)
.ok_or_else(|| anyhow!("Failed to parse the version of `{cmd_name}`"))
}

if let Some(solana_version) = &cfg.toolchain.solana_version {
Expand Down Expand Up @@ -633,11 +633,10 @@ fn override_toolchain(cfg_override: &ConfigOverride) -> Result<RestoreToolchainC
}

// Hide the installation progress if the version is already installed
let is_installed = std::str::from_utf8(&output.stdout)?.lines().any(|line| {
parse_version(line)
.map(|line_version| line_version == version)
.unwrap_or(false)
});
let is_installed = std::str::from_utf8(&output.stdout)?
.lines()
.filter_map(parse_version)
.any(|line_version| line_version == version);
let (stderr, stdout) = if is_installed {
(Stdio::null(), Stdio::null())
} else {
Expand Down

0 comments on commit 7682dd9

Please sign in to comment.