Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): update DisplayVersion on rustup self update #3770

Merged
merged 11 commits into from
Apr 21, 2024
Prev Previous commit
Next Next commit
refactor(self-update): extract get_and_parse_new_rustup_version()
  • Loading branch information
rami3l committed Apr 21, 2024
commit d8aacc1bc91491eb31bfaadcae400b453ae2ff5a
13 changes: 7 additions & 6 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 1106,9 @@ pub(crate) fn update(cfg: &Cfg) -> Result<utils::ExitCode> {

match prepare_update()? {
Some(setup_path) => {
let version = match get_new_rustup_version(&setup_path) {
Some(new_version) => parse_new_rustup_version(new_version),
None => {
err!("failed to get rustup version");
return Ok(utils::ExitCode(1));
}
let Some(version) = get_and_parse_new_rustup_version(&setup_path) else {
err!("failed to get rustup version");
return Ok(utils::ExitCode(1));
};

let _ = common::show_channel_update(
Expand All @@ -1135,6 1132,10 @@ pub(crate) fn update(cfg: &Cfg) -> Result<utils::ExitCode> {
Ok(utils::ExitCode(0))
}

fn get_and_parse_new_rustup_version(path: &Path) -> Option<String> {
rbtcollins marked this conversation as resolved.
Show resolved Hide resolved
get_new_rustup_version(path).map(parse_new_rustup_version)
}

fn get_new_rustup_version(path: &Path) -> Option<String> {
match Command::new(path).arg("--version").output() {
Err(_) => None,
Expand Down