Skip to content

Commit

Permalink
fix(iroh-net): handle non git environments in build
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jul 18, 2023
1 parent b1ff368 commit a645cbe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions iroh-net/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use duct::cmd;

fn main() {
// Git commit
println!("cargo:rustc-env=GIT_COMMIT={}", get_git_commit().unwrap());
println!("cargo:rustc-env=GIT_COMMIT={}", get_git_commit());

// Rustc version
println!(
Expand All @@ -13,8 +13,12 @@ fn main() {
);
}

fn get_git_commit() -> std::io::Result<String> {
cmd!("git", "rev-parse", "HEAD").read()
fn get_git_commit() -> String {
if let Ok(commit) = cmd!("git", "rev-parse", "HEAD").read() {
commit
} else {
"git_unavailable".to_string()
}
}

fn get_rustc_version() -> io::Result<String> {
Expand Down

0 comments on commit a645cbe

Please sign in to comment.