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

Print rustup version after update #614

Merged
merged 1 commit into from Aug 1, 2016

Conversation

Projects
None yet
2 participants
@julienXX
Copy link
Contributor

julienXX commented Jul 25, 2016

Fixes #542

@@ -1069,7 +1071,7 @@ pub fn update() -> Result<()> {
}
let setup_path = try!(prepare_update());
if let Some(ref p) = setup_path {
info!("rustup updated successfully");
info!("rustup updated successfully to {}", VERSION);

This comment has been minimized.

@brson

brson Jul 25, 2016

Contributor

By printing CARGO_PKG_VERSION here rustup will be printing the version of the currently running version of rustup. Instead, what we want is to print the version we just downloaded (here represented by setup_path). So this is instead going to need to run the executable at setup_path with --version and parse out the new version number.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jul 25, 2016

Thanks @julienXX !

@julienXX julienXX force-pushed the julienXX:print-new-version-after-update branch from b35bb04 to a23c403 Jul 26, 2016

@julienXX

This comment has been minimized.

Copy link
Contributor Author

julienXX commented Jul 26, 2016

@brson Oh okay, I should have thought about that. Thanks!
I updated the PR with getting the version of the downloaded rustup.
Do you have any advice on how I should test this? The current test pass but I don't think it's really adequate.

let re = Regex::new(r"\d+.\d+.\d+").unwrap();
let capture = re.captures(&string_version).unwrap().at(0).unwrap();
Ok(String::from(capture))
}

This comment has been minimized.

@brson

brson Jul 26, 2016

Contributor

Since this code is on the super-important upgrade path, let's be a little more defensive. What happens if the new executable doesn't run? Seems like it could happen. What happens if it fails? What happens if the output of --version changes? Seems like we might want to do that (for example returning a version like "2.0.0-rc1"). Instead of unwraps here can they return errors instead? Then have the caller convert those errors to a placeholder string like "(unknown)".

An aside, if the executable fails to run that would be a bad sign - it might be worth thinking about turning that into a hard error and failing the upgrade. But that can be a different PR.

This comment has been minimized.

@julienXX

julienXX Jul 26, 2016

Author Contributor

Yes absolutely! I'll update the code to be more defensive. Do you feel like regexp is the way to go or could a string split be sufficient?

This comment has been minimized.

@brson

brson Jul 29, 2016

Contributor

Regexp is good!

This comment has been minimized.

@brson

brson Jul 29, 2016

Contributor

Sorry for the slow response.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jul 26, 2016

The test is good enough I think. Yeah, it could be better by having a different version number, but the effort to make that happen isn't worth it.

@julienXX julienXX force-pushed the julienXX:print-new-version-after-update branch from a23c403 to 5ea4473 Aug 1, 2016

@julienXX

This comment has been minimized.

Copy link
Contributor Author

julienXX commented Aug 1, 2016

@brson I updated the code to be more defensive. Also it now exit the process if the executable fails to run.

@brson brson merged commit a181b2b into rust-lang:master Aug 1, 2016

0 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@brson

This comment has been minimized.

Copy link
Contributor

brson commented Aug 1, 2016

Looks great. Thanks @julienXX !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.