mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
change(githash): provide date and hash
This commit is contained in:
parent
39656e92be
commit
5b716515bb
@ -79,9 +79,11 @@ impl Client {
|
|||||||
// TODO: Voxygen should display this.
|
// TODO: Voxygen should display this.
|
||||||
if server_info.git_hash != common::util::GIT_HASH.to_string() {
|
if server_info.git_hash != common::util::GIT_HASH.to_string() {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"Git hash mismatch between client and server: {} vs {}",
|
"Server is running {}[{}], you are running {}[{}], versions might be incompatible!",
|
||||||
server_info.git_hash,
|
server_info.git_hash,
|
||||||
common::util::GIT_HASH
|
server_info.git_date,
|
||||||
|
common::util::GIT_HASH,
|
||||||
|
common::util::GIT_DATE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,13 @@ use std::process::Command;
|
|||||||
fn main() {
|
fn main() {
|
||||||
// Get the current githash
|
// Get the current githash
|
||||||
match Command::new("git")
|
match Command::new("git")
|
||||||
.args(&["rev-parse", "--short", "HEAD"])
|
.args(&[
|
||||||
|
"log",
|
||||||
|
"-n",
|
||||||
|
"1",
|
||||||
|
"--pretty=format:%h %cd",
|
||||||
|
"--date=format:%Y-%m-%d-%H:%M",
|
||||||
|
])
|
||||||
.output()
|
.output()
|
||||||
{
|
{
|
||||||
Ok(output) => match String::from_utf8(output.stdout) {
|
Ok(output) => match String::from_utf8(output.stdout) {
|
||||||
|
@ -20,6 +20,7 @@ pub struct ServerInfo {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub git_hash: String,
|
pub git_hash: String,
|
||||||
|
pub git_date: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -1,4 +1,21 @@
|
|||||||
pub const GIT_HASH: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
|
pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
|
||||||
|
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
pub static ref GIT_HASH: &'static str = include_str!(concat!(env!("OUT_DIR"), "/githash")).split(" ").nth(0).unwrap();
|
||||||
|
pub static ref GIT_DATE: &'static str = include_str!(concat!(env!("OUT_DIR"), "/githash")).split(" ").nth(1).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for GIT_HASH {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for GIT_DATE {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use vek::{Mat3, Rgb, Rgba, Vec3};
|
use vek::{Mat3, Rgb, Rgba, Vec3};
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ impl Server {
|
|||||||
name: settings.server_name.clone(),
|
name: settings.server_name.clone(),
|
||||||
description: settings.server_description.clone(),
|
description: settings.server_description.clone(),
|
||||||
git_hash: common::util::GIT_HASH.to_string(),
|
git_hash: common::util::GIT_HASH.to_string(),
|
||||||
|
git_date: common::util::GIT_DATE.to_string(),
|
||||||
},
|
},
|
||||||
metrics: ServerMetrics::new(settings.metrics_address),
|
metrics: ServerMetrics::new(settings.metrics_address),
|
||||||
accounts: AuthProvider::new(),
|
accounts: AuthProvider::new(),
|
||||||
|
@ -40,7 +40,7 @@ impl ServerMetrics {
|
|||||||
);
|
);
|
||||||
let entity_count = IntGauge::with_opts(opts).unwrap();
|
let entity_count = IntGauge::with_opts(opts).unwrap();
|
||||||
let opts = Opts::new("veloren_build_info", "Build information")
|
let opts = Opts::new("veloren_build_info", "Build information")
|
||||||
.const_label("hash", common::util::GIT_HASH)
|
.const_label("hash", &common::util::GIT_HASH)
|
||||||
.const_label("version", "");
|
.const_label("version", "");
|
||||||
let build_info = IntGauge::with_opts(opts).unwrap();
|
let build_info = IntGauge::with_opts(opts).unwrap();
|
||||||
let opts = Opts::new(
|
let opts = Opts::new(
|
||||||
|
Loading…
Reference in New Issue
Block a user