mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
add global git hash constant
This commit is contained in:
parent
02180db437
commit
de2dbcef45
@ -66,6 +66,15 @@ impl Client {
|
||||
entity_uid,
|
||||
server_info,
|
||||
}) => {
|
||||
// TODO: Voxygen should display this.
|
||||
if server_info.git_hash != common::util::GIT_HASH.to_string() {
|
||||
log::warn!(
|
||||
"Git hash mismatch between client and server: {} vs {}",
|
||||
server_info.git_hash,
|
||||
common::util::GIT_HASH
|
||||
);
|
||||
}
|
||||
|
||||
let state = State::from_state_package(ecs_state);
|
||||
let entity = state
|
||||
.ecs()
|
||||
|
29
common/build.rs
Normal file
29
common/build.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
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) => {
|
||||
let mut target = File::create(
|
||||
Path::new(
|
||||
&env::var("OUT_DIR").expect("failed to query OUT_DIR environment variable"),
|
||||
)
|
||||
.join("githash"),
|
||||
)
|
||||
.expect("failed to create git hash file!");
|
||||
target
|
||||
.write_all(hash.trim().as_bytes())
|
||||
.expect("failed to write to file!");
|
||||
}
|
||||
Err(e) => panic!("failed to convert git output to UTF-8: {}", e),
|
||||
},
|
||||
Err(e) => panic!("failed to retrieve current git commit hash: {}", e),
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ pub enum RequestStateError {
|
||||
pub struct ServerInfo {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub git_hash: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -1 +1 @@
|
||||
|
||||
pub const GIT_HASH: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
|
||||
|
@ -106,6 +106,7 @@ impl Server {
|
||||
server_info: ServerInfo {
|
||||
name: settings.server_name.clone(),
|
||||
description: settings.server_description.clone(),
|
||||
git_hash: common::util::GIT_HASH.to_string(),
|
||||
},
|
||||
server_settings: settings,
|
||||
};
|
||||
|
@ -1,14 +0,0 @@
|
||||
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),
|
||||
}
|
||||
}
|
@ -322,10 +322,7 @@ impl Hud {
|
||||
let mut events = Vec::new();
|
||||
let ref mut ui_widgets = self.ui.set_widgets();
|
||||
|
||||
let version = match std::env::var("GIT_HASH") {
|
||||
Ok(hash) => format!("{}-{}", env!("CARGO_PKG_VERSION"), hash),
|
||||
Err(_) => env!("CARGO_PKG_VERSION").to_owned(),
|
||||
};
|
||||
let version = format!("{}-{}", env!("CARGO_PKG_VERSION"), common::util::GIT_HASH);
|
||||
|
||||
// Nametags and healthbars
|
||||
if self.show.ingame {
|
||||
|
Loading…
Reference in New Issue
Block a user