From a6b022e70b190b796e24c9060f41eda3fc8ac269 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sun, 17 Mar 2024 21:33:54 +0100 Subject: [PATCH] feat: added git info to startup version string --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 1 + src/main.rs | 8 +++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1549f52..d598890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -423,6 +423,7 @@ version = "0.1.0" dependencies = [ "actix-web", "anyhow", + "compile-time-run", "dotenv", "env_logger", "log", @@ -435,6 +436,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "compile-time-run" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b5affba7c91c039a483065125dd8c6d4a0985e1e9ac5ab6dffdea4fe4e637f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "const-oid" version = "0.9.6" diff --git a/Cargo.toml b/Cargo.toml index 2bb20aa..25d00e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ anyhow = "1.0.81" log = "0.4.21" env_logger = "0.11.3" dotenv = "0.15.0" +compile-time-run = "0.2.12" actix-web = "4.5.1" sqlx = { version = "0.7.4", features = ["runtime-tokio", "tls-native-tls"] } diff --git a/src/main.rs b/src/main.rs index 7f224d3..3ec1925 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod config; use anyhow::Result; +use compile_time_run::run_command_str; use config::Config; use log::info; @@ -9,7 +10,12 @@ async fn main() -> Result<()> { dotenv::dotenv()?; env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); - info!("Starting Cipher Relay (v{} - )", env!("CARGO_PKG_VERSION")); + info!( + "Starting Cipher Relay (v{} - git: {}/{})", + env!("CARGO_PKG_VERSION"), + run_command_str!("git", "branch", "--show-current"), + run_command_str!("git", "describe", "--always", "--dirty=-modified") + ); let config = Config::from_env()?;