From 093bc42e9703f6cb6cccbe285e19c2092e608aa1 Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Fri, 30 May 2025 23:11:51 -0400 Subject: [PATCH] Add git commit hash to version info on HTTP servers --- Cargo.lock | 23 +++++++++++++++++++++++ Cargo.toml | 1 + auth/Cargo.toml | 1 + auth/src/main.rs | 3 ++- cdn/Cargo.toml | 1 + cdn/src/main.rs | 3 ++- rc_microtransactions/Cargo.toml | 1 + rc_microtransactions/src/main.rs | 3 ++- 8 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efcc087..d49b222 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -447,6 +447,7 @@ version = "0.2.0" dependencies = [ "clap", "env_logger", + "git-version", "hex", "jsonwebtoken", "libfj", @@ -700,6 +701,7 @@ dependencies = [ "actix-web", "clap", "env_logger", + "git-version", "log", "tokio", "zip", @@ -1423,6 +1425,26 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "git-version" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19" +dependencies = [ + "git-version-macro", +] + +[[package]] +name = "git-version-macro" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "glob" version = "0.3.2" @@ -3102,6 +3124,7 @@ name = "rc_microtransactions" version = "0.2.0" dependencies = [ "env_logger", + "git-version", "libfj", "log", "rocket", diff --git a/Cargo.toml b/Cargo.toml index 1de3626..f52f9eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,3 +37,4 @@ serde = { version = "1.0", features = [ "derive" ] } serde_json = "1.0" async-trait = "0.1" chrono = "0.4" +git-version = "0.3" diff --git a/auth/Cargo.toml b/auth/Cargo.toml index 05ddbfc..c146968 100644 --- a/auth/Cargo.toml +++ b/auth/Cargo.toml @@ -26,3 +26,4 @@ jsonwebtoken = "9" clap.workspace = true rc_core = { version = "*", optional = true, path = "../rc_core" } serde.workspace = true +git-version.workspace = true diff --git a/auth/src/main.rs b/auth/src/main.rs index 33a5023..afc6fcd 100644 --- a/auth/src/main.rs +++ b/auth/src/main.rs @@ -10,10 +10,11 @@ mod robocraft; fn index() -> String { let name = env!("CARGO_PKG_NAME"); let version = env!("CARGO_PKG_VERSION"); + let git_version = git_version::git_version!(args = ["--always", "--dirty=+"]); let authors = env!("CARGO_PKG_AUTHORS"); let license = env!("CARGO_PKG_LICENSE"); let repo = env!("CARGO_PKG_REPOSITORY"); - format!("{} {} by [{}]\n{}\n{}", name, version, authors, license, repo) + format!("{} {}:{} by [{}]\n{}\n{}", name, version, git_version, authors, license, repo) } #[rocket::launch] diff --git a/cdn/Cargo.toml b/cdn/Cargo.toml index 94e0e5e..58cdbcd 100644 --- a/cdn/Cargo.toml +++ b/cdn/Cargo.toml @@ -15,3 +15,4 @@ log.workspace = true env_logger.workspace = true tokio = { version = "1.43", features = [ "rt-multi-thread" ] } zip = "4" +git-version.workspace = true diff --git a/cdn/src/main.rs b/cdn/src/main.rs index 23ae9c2..9d73ac2 100644 --- a/cdn/src/main.rs +++ b/cdn/src/main.rs @@ -7,10 +7,11 @@ use actix_web::{App, HttpServer, Responder}; async fn index() -> impl Responder { let name = env!("CARGO_PKG_NAME"); let version = env!("CARGO_PKG_VERSION"); + let git_version = git_version::git_version!(args = ["--always", "--dirty=+"]); let authors = env!("CARGO_PKG_AUTHORS"); let license = env!("CARGO_PKG_LICENSE"); let repo = env!("CARGO_PKG_REPOSITORY"); - format!("{} {} by [{}]\n{}\n{}", name, version, authors, license, repo) + format!("{} {}{} by [{}]\n{}\n{}", name, version, git_version, authors, license, repo) } #[actix_web::main] diff --git a/rc_microtransactions/Cargo.toml b/rc_microtransactions/Cargo.toml index 06d36b2..55635e9 100644 --- a/rc_microtransactions/Cargo.toml +++ b/rc_microtransactions/Cargo.toml @@ -12,3 +12,4 @@ rocket.workspace = true libfj.workspace = true log.workspace = true env_logger.workspace = true +git-version.workspace = true diff --git a/rc_microtransactions/src/main.rs b/rc_microtransactions/src/main.rs index e5efeb6..8b7e68f 100644 --- a/rc_microtransactions/src/main.rs +++ b/rc_microtransactions/src/main.rs @@ -5,10 +5,11 @@ mod robocraft; fn index() -> String { let name = env!("CARGO_PKG_NAME"); let version = env!("CARGO_PKG_VERSION"); + let git_version = git_version::git_version!(args = ["--always", "--dirty=+"]); let authors = env!("CARGO_PKG_AUTHORS"); let license = env!("CARGO_PKG_LICENSE"); let repo = env!("CARGO_PKG_REPOSITORY"); - format!("{} {} by [{}]\n{}\n{}", name, version, authors, license, repo) + format!("{} {}:{} by [{}]\n{}\n{}", name, version, git_version, authors, license, repo) } #[rocket::launch]