Skip to content

Commit

Permalink
Show the git HEAD sha in version output
Browse files Browse the repository at this point in the history
The argument `migrate-wicked --version` show something like
  migrate-wicked 0.1.0~7c9199b0f
  • Loading branch information
cfconrad authored and jcronenberg committed Aug 30, 2024
1 parent 6b4a27d commit 892e61f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions rust/migrate-wicked/build.rs
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion rust/migrate-wicked/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 892e61f

Please sign in to comment.