-
Notifications
You must be signed in to change notification settings - Fork 943
Add --version switch #615
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
Add --version switch #615
Conversation
Add --version switch, which prints a short hash of the current commit. Fix rust-lang#612
Doesn't this print the commit when rustfmt is run, not when rustfmt is compiled? That seems wrong. |
Yeah, I think the right approach is to get the commit hash at compile time. Probably the best way to do this is to make a small syntax extension, however, this would mean we can't use stable Rust :-( Alternatively, we could use a Cargo build script - I remember we used to have one, but it was removed because it was annoying for various reasons. I wonder how rustc gets its version hash - I assume some combination of unstable Rust and its horrific system of make files - but it might be worth checking out to see if there is some way of passing the data in. |
rustc sets |
Ah cool, I wonder if Cargo lets you set environment variables without having to use a build script? |
You're right, my commit is wrong. Nonetheless, I have learned that this approach might be problematic. |
Using a git hook to save the hash into a file and then |
Print version acquired from Cargo when building. If built using rustc directly, print X.X.X
Github only has webhooks, so we would need a server to process each of the commits. I think that would be an overkill. "--version" or "-V" now prints version as defined in |
@JanLikar sorry for the lack of attention, I have been on vacation the last week, but this has been sitting even longer than that. I think we should land this, the PR looks good and we can bump versions when we feel like it. Thanks for the PR, and sorry again it took so long to land. @mrbt that is the current state of the PR |
@nrc It's ok, no harm done. I hope you had a great vacation! |
Add --version switch, which prints a short hash of the current commit. Fix #612