From 892e61f742ec03475ae017b106f72751acbd9989 Mon Sep 17 00:00:00 2001 From: Clemens Famulla-Conrad Date: Fri, 30 Aug 2024 15:08:10 +0200 Subject: [PATCH 1/2] Show the git HEAD sha in version output The argument `migrate-wicked --version` show something like migrate-wicked 0.1.0~7c9199b0f --- rust/migrate-wicked/build.rs | 11 +++++++++++ rust/migrate-wicked/src/main.rs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 rust/migrate-wicked/build.rs diff --git a/rust/migrate-wicked/build.rs b/rust/migrate-wicked/build.rs new file mode 100644 index 0000000000..cc9d01139b --- /dev/null +++ b/rust/migrate-wicked/build.rs @@ -0,0 +1,11 @@ +use std::process::Command; + +fn main() { + let output = Command::new("git") + .args(&["rev-parse", "HEAD"]) + .output() + .unwrap(); + let mut git_hash = String::from_utf8(output.stdout).unwrap(); + git_hash.truncate(9); + println!("cargo:rustc-env=GIT_HEAD={}", git_hash); +} diff --git a/rust/migrate-wicked/src/main.rs b/rust/migrate-wicked/src/main.rs index 991f10427d..4c2b19bb4e 100644 --- a/rust/migrate-wicked/src/main.rs +++ b/rust/migrate-wicked/src/main.rs @@ -17,7 +17,7 @@ use std::process::{ExitCode, Termination}; use tokio::sync::OnceCell; #[derive(Parser)] -#[command(name = "migrate-wicked", version, about, long_about = None)] +#[command(name = "migrate-wicked", version(concat!(env!("CARGO_PKG_VERSION"),"~",env!("GIT_HEAD"))), about, long_about = None)] struct Cli { #[clap(flatten)] global_opts: GlobalOpts, From 9cd64b13550e7ab1e5e436634c1dc1857aafc693 Mon Sep 17 00:00:00 2001 From: Jorik Cronenberg Date: Fri, 30 Aug 2024 16:50:04 +0200 Subject: [PATCH 2/2] Apply clippy suggestion --- rust/migrate-wicked/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/migrate-wicked/build.rs b/rust/migrate-wicked/build.rs index cc9d01139b..58305f6d6a 100644 --- a/rust/migrate-wicked/build.rs +++ b/rust/migrate-wicked/build.rs @@ -2,7 +2,7 @@ use std::process::Command; fn main() { let output = Command::new("git") - .args(&["rev-parse", "HEAD"]) + .args(["rev-parse", "HEAD"]) .output() .unwrap(); let mut git_hash = String::from_utf8(output.stdout).unwrap();