-
Notifications
You must be signed in to change notification settings - Fork 258
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
Expose version info in CLI tool with build-time obtained git hash #787
Conversation
output_git_short_hash(); | ||
} | ||
|
||
fn output_git_short_hash() { |
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.
you could do something similar as substrate to get a better error message if git fails:
match Command::new("git").args(&["rev-parse", "--short=11", "HEAD"]).output() {
Ok(o) if o.status.success() => {
let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned();
Cow::from(sha)
},
Ok(o) => {
println!("cargo:warning=Git command failed with status: {}", o.status);
Cow::from("unknown")
},
Err(err) => {
println!("cargo:warning=Failed to execute git command: {}", err);
Cow::from("unknown")
},
}
I guess you want to fail the entire thing once it errors, I have no issues with that :)
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.
Perhaps the expect output is clear enough not sure
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.
Nice idea! I'd never expect the git tool not to exist really in a build env I guess, but maybe worth doing this just incase! :)
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 added this; nice suggestion!
You could have cherry-picked @DaviRain-Su commit to give him some kudos for the work but yeah kudos in the PR description works as well I guess :P |
I'll remember that for next time; I wanted to give kudos for sure, but it's a pain working with remote branches so I was lazy :) |
I haven't merged this yet because I'm playing with |
It took me far too long to see that the rerun-if-changed commands I was using were wrong, but it all should work now :) |
Builds off @DaviRain-Su's work in #776 and provides version info in the subxt CLI command, making the git hash be a compile-time included string.
Closes #739