@@ -520,10 +520,10 @@ fn run_vscode_compatible(variant: VSCodeVariant, ctx: &ExecutionContext) -> Resu
520520
521521 // VSCode has update command only since 1.86 version ("january 2024" update), disable the update for prior versions
522522 //
523- // The command `code --version` has two possible formats:
523+ // The output of `code --version` has two possible formats:
524524 // 1. 3 lines: version, git commit, instruction set. We parse only the first one
525- // This is confirmed from deb-get ( apt)
526- // 2. 1 line: bin-name 1.2.3 (commit 123abc): example `code-insiders 1.106.0 (commit 48cdf17f0e856e1daca2ad2747814085a2453df0)`
525+ // This is confirmed on an install from the apt repository
526+ // 2. 1 line: ' bin-name 1.2.3 (commit 123abc)', example: `code-insiders 1.106.0 (commit 48cdf17f0e856e1daca2ad2747814085a2453df0)`
527527 // See https://github.com/topgrade-rs/topgrade/issues/1605, confirmed from Microsoft website
528528 // This should apply to VSCodium as well.
529529
@@ -543,7 +543,7 @@ fn run_vscode_compatible(variant: VSCodeVariant, ctx: &ExecutionContext) -> Resu
543543 line. split_whitespace ( ) . nth ( 1 ) . ok_or_else ( || {
544544 eyre ! ( output_changed_message!(
545545 & format!( "{bin_name} --version" ) ,
546- format!( "No whitespace after '{bin_name}'" )
546+ format!( "No version after '{bin_name}'" )
547547 ) )
548548 } ) ?
549549 } else {
@@ -555,17 +555,17 @@ fn run_vscode_compatible(variant: VSCodeVariant, ctx: &ExecutionContext) -> Resu
555555
556556 // Strip leading zeroes because `semver` does not allow them, but VSCodium uses them sometimes.
557557 // This is not the case for VSCode, but just in case, and it can't really cause any issues.
558- let version = Version :: parse (
559- & version_string
560- . split ( '.' )
561- . map ( |s| if s == "0" { "0" } else { s . trim_start_matches ( '0' ) } )
562- . collect :: < Vec < _ > > ( )
563- . join ( "." ) ,
564- )
565- // Raise any errors in parsing the version
566- // The benefit of handling VSCodium versions so old that the version format is something
567- // unexpected is outweighed by the benefit of failing fast on new breaking versions
568- . wrap_err_with ( || output_changed_message ! ( & format!( "{bin_name} --version" ) , "Invalid version" ) ) ?;
558+ let version_string = version_string
559+ . split ( '.' )
560+ . map ( |s| if s == "0" { "0" } else { s . trim_start_matches ( '0' ) } )
561+ . collect :: < Vec < _ > > ( )
562+ . join ( "." ) ;
563+
564+ let version = Version :: parse ( & version_string )
565+ // Raise any errors in parsing the version
566+ // The benefit of handling VSCodium versions so old that the version format is something
567+ // unexpected is outweighed by the benefit of failing fast on new breaking versions
568+ . wrap_err_with ( || output_changed_message ! ( & format!( "{bin_name} --version" ) , "Invalid version" ) ) ?;
569569
570570 debug ! ( "Detected {name} version as: {version}" ) ;
571571
0 commit comments