add git commit hash to debug window

This commit is contained in:
Songtronix 2019-06-28 12:08:12 +00:00 committed by Marcel
parent 42c5e671a1
commit eb28ba94f6
2 changed files with 20 additions and 2 deletions

14
voxygen/build.rs Normal file
View File

@ -0,0 +1,14 @@
use std::process::Command;
fn main() {
match Command::new("git")
.args(&["rev-parse", "--short", "HEAD"])
.output()
{
Ok(output) => match String::from_utf8(output.stdout) {
Ok(hash) => println!("cargo:rustc-env=GIT_HASH={}", hash),
Err(e) => println!("failed to convert git output to UTF-8: {}", e),
},
Err(e) => println!("failed to retrieve current git commit hash: {}", e),
}
}

View File

@ -305,7 +305,11 @@ impl Hud {
) -> Vec<Event> {
let mut events = Vec::new();
let ref mut ui_widgets = self.ui.set_widgets();
let version = env!("CARGO_PKG_VERSION");
let version = match std::env::var("GIT_HASH") {
Ok(hash) => format!("{}-{}", env!("CARGO_PKG_VERSION"), hash),
Err(_) => env!("CARGO_PKG_VERSION").to_owned(),
};
// Don't show anything if the UI is toggled off.
if !self.show.ui {
@ -421,7 +425,7 @@ impl Hud {
// Display debug window.
if self.show.debug {
// Alpha Version
Text::new(version)
Text::new(&version)
.top_left_with_margins_on(ui_widgets.window, 5.0, 5.0)
.font_size(14)
.font_id(self.fonts.opensans)