-
-
Notifications
You must be signed in to change notification settings - Fork 21
Allow getting version info for a specified command #4
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
Conversation
The failure is from bumping semver to include dtolnay/semver@0faefa8, which changes how pre-release tags are handled with requirements. I'll take a closer look tomorrow. |
SemVerError(semver::SemVerError), | ||
/// The pre-release tag is unknown. | ||
UnknownPreReleaseTag(Identifier), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to add this as is, but I feel like half of these error scenarios could reasonably be declared unexpected failures that don't need to appear in the Result. :)
Eg, rustc changing to non-utf8 output or not using semver compatible version numbers is unlikely to be an error, ever.
Though I guess since a) there are already many error variants in that enum and b) RUSTC
might be a wrapper or alternate compiler, just covering everything is probably for the best anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just translated the panics directly to variants. If you prefer, all but CouldNotExecuteCommand
could be some kind of catch all parse error that wraps the cause as Option<Box<Error>>
. I'm happy either way: all I want is a way not to panic! :-)
Seems like the dtolnay/semver#54 change makes it no longer possible to use semver version requirements to sort rustc versions while ignoring prerelease tags, that is it appears that Which is kinda annoying because that kind of usage was the main motivation for exposing semver in this crate. :) I wonder if I should add rustc-release-train-specific functions that ignore the prelrease tags, or specify this crate as doing this automatically... (the latter is probably a bad idea though) |
I think it's the other way around:
Former makes more sense to me. Arguably, the new behavior is fixing a bug. To get the behavior that makes sense for release trains, we could just use the
even though this does not:
|
Ah, interesting. I had assumed that the Ord impl on Version follows the same scheme as version requirments, but if it doesn't then thats a fine replacement, yeah. Still have to change the example code and maybe deprecate |
Here are some of approaches:
I kind of lean towards 4. Changing panics to |
Yeah, will probably just remove it. |
semver 0.2 was the first to include a fix to how `VersionReq` comparisons work with pre-release identifiers. The fix results in, eg, version_matches(">= 1.4.0") not matching for a compiler version `1.8.0-nightly`. For more details, see dtolnay/semver#54. This makes `version_matches()` far less useful, and so it is removed. It's still possible to get the original intent by using the `Ord` impl on `semver::Version`. To make this more convenient, `semver::Version` is exported from this crate. This is a breaking change.
This gives the choice of how to handle the error to the downstream user, making it easier to use rustc_version as a library in non-build-script contexts. This is a breaking change.
This allows controlling what command to use without needing to set the `RUSTC` environment variable.
57cabfc
to
3b4fca5
Compare
I just opened #5 for that change and rebased this PR on top of that one. |
These commits add support for getting version info for a specified command. Along the way, functions are changed to return an error instead of panicking, making them more flexible for downstream users.