mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
build-script-utils: allow reading the git commit hash from env var (#10845)
* build-script-utils: allow reading the git commit hash from env var * build-script-utils: make the env var name substrate specific
This commit is contained in:
@@ -20,21 +20,23 @@ use std::{borrow::Cow, process::Command};
|
|||||||
|
|
||||||
/// Generate the `cargo:` key output
|
/// Generate the `cargo:` key output
|
||||||
pub fn generate_cargo_keys() {
|
pub fn generate_cargo_keys() {
|
||||||
let output = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output();
|
let commit = if let Ok(hash) = std::env::var("SUBSTRATE_CLI_GIT_COMMIT_HASH") {
|
||||||
|
Cow::from(hash.trim().to_owned())
|
||||||
let commit = match output {
|
} else {
|
||||||
Ok(o) if o.status.success() => {
|
match Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output() {
|
||||||
let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned();
|
Ok(o) if o.status.success() => {
|
||||||
Cow::from(sha)
|
let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned();
|
||||||
},
|
Cow::from(sha)
|
||||||
Ok(o) => {
|
},
|
||||||
println!("cargo:warning=Git command failed with status: {}", o.status);
|
Ok(o) => {
|
||||||
Cow::from("unknown")
|
println!("cargo:warning=Git command failed with status: {}", o.status);
|
||||||
},
|
Cow::from("unknown")
|
||||||
Err(err) => {
|
},
|
||||||
println!("cargo:warning=Failed to execute git command: {}", err);
|
Err(err) => {
|
||||||
Cow::from("unknown")
|
println!("cargo:warning=Failed to execute git command: {}", err);
|
||||||
},
|
Cow::from("unknown")
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("cargo:rustc-env=SUBSTRATE_CLI_IMPL_VERSION={}", get_version(&commit))
|
println!("cargo:rustc-env=SUBSTRATE_CLI_IMPL_VERSION={}", get_version(&commit))
|
||||||
|
|||||||
Reference in New Issue
Block a user