Skip to content
Snippets Groups Projects
Commit 7e5424dd authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Don't fail the build when no git is found (#5589)

parent 7cdfaff1
No related merge requests found
......@@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use platforms::*;
use std::process::Command;
use std::{borrow::Cow, process::Command};
/// Generate the `cargo:` key output
pub fn generate_cargo_keys() {
......@@ -23,15 +23,22 @@ pub fn generate_cargo_keys() {
.args(&["rev-parse", "--short", "HEAD"])
.output();
match output {
let commit = match output {
Ok(o) if o.status.success() => {
let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned();
println!("cargo:rustc-env=SUBSTRATE_CLI_IMPL_VERSION={}", get_version(sha.as_str()))
Cow::from(sha)
}
Ok(o) => eprintln!("cargo:warning=Git command failed with status: {}", o.status),
Err(err) => eprintln!("cargo:warning=Failed to execute git command: {}", err),
}
Ok(o) => {
println!("cargo:warning=Git command failed with status: {}", o.status);
Cow::from("unknown-commit")
},
Err(err) => {
println!("cargo:warning=Failed to execute git command: {}", err);
Cow::from("unknown-commit")
},
};
println!("cargo:rustc-env=SUBSTRATE_CLI_IMPL_VERSION={}", get_version(&commit))
}
fn get_platform() -> String {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment