From 751f41bc5e7a58676231ee296550cec1aa714aa2 Mon Sep 17 00:00:00 2001 From: Matt Thomson <771863+matt-thomson@users.noreply.github.com> Date: Wed, 16 Apr 2025 06:35:30 +0100 Subject: [PATCH] Handle format change in asdf version (#1127) As of the latest version, this now has the format 0.16.7 - i.e. without the hash part. This commit makes it so that both formats work. Fixes #1096 --- src/steps/os/unix.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index aa1ae9f6..0e20ee39 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -642,14 +642,17 @@ pub fn run_asdf(ctx: &ExecutionContext) -> Result<()> { // v0.15.0-31e8c93 // // ``` + // ``` + // $ asdf version + // v0.16.7 + // ``` let version_stdout = version_output.stdout.trim(); // trim the starting 'v' let mut remaining = version_stdout.trim_start_matches('v'); - let idx = remaining - .find('-') - .ok_or_else(|| eyre!(output_changed_message!("asdf version", "no dash (-) found")))?; - // remove the hash part - remaining = &remaining[..idx]; + // remove the hash part if present + if let Some(idx) = remaining.find('-') { + remaining = &remaining[..idx]; + } let version = Version::parse(remaining).wrap_err_with(|| output_changed_message!("asdf version", "invalid version"))?; if version < Version::new(0, 15, 0) {