From 5f5c34640f9a568b46fabae20210edf41e31c978 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 1 Jan 2023 09:46:44 -0600 Subject: [PATCH] Apply patch from perillamint on github use git hash to describe version number --- src/build.rs | 1 + src/config.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/build.rs b/src/build.rs index 1c7e714..ebac904 100644 --- a/src/build.rs +++ b/src/build.rs @@ -6,6 +6,7 @@ fn git_info() { if output.status.success() { let git_hash = String::from_utf8_lossy(&output.stdout); println!("cargo:rustc-env=GIT_HASH={}", git_hash); + println!("cargo:rustc-env=GIT_SHORT_HASH={}", &git_hash[..8]) } } diff --git a/src/config.rs b/src/config.rs index 52657cf..badf9ec 100644 --- a/src/config.rs +++ b/src/config.rs @@ -367,7 +367,7 @@ impl Config { fn git_version() -> Option { let branch = Self::git_branch()?; - let hash = Self::git_hash()?; + let hash = Self::git_short_hash()?; Some(format!("{}-{}", branch, hash)) } @@ -388,6 +388,10 @@ impl Config { option_env!("GIT_HASH") } + fn git_short_hash() -> Option<&'static str> { + option_env!("GIT_SHORT_HASH") + } + pub(crate) fn user_agent(&self) -> String { format!( "{} ({}/{}; +{})",