nix: Compile commit hash into program version
Changes build.rs to take the GIT_HEAD environment variable into account if `git rev-parse` is unable to determine the current commit hash.
This commit is contained in:
parent
fb13e5f970
commit
4b1ca18d0c
3
build.rs
3
build.rs
|
|
@ -1,4 +1,5 @@
|
|||
use std::process::Command;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
// Set a build-time `GIT_HEAD` env var which includes the commit id;
|
||||
|
|
@ -16,7 +17,7 @@ fn main() {
|
|||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| String::from("unknown"));
|
||||
.unwrap_or(env::var("GIT_HEAD").unwrap_or("unknown".into()));
|
||||
|
||||
println!("cargo:rustc-env=GIT_HEAD={hash}");
|
||||
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
|
||||
|
|
|
|||
Loading…
Reference in New Issue