Skip to content
Myr

build: emit warning if git is missing during build

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Closes #3057

authored by kevichi7 · committed by Andrew Gallant · parent 2ebd768 · Browse files · 1 file+20 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−5 removed

  • other:+20 added−5 removed

1 file+20 added−5 removed

modified:build.rs+20 added-5 removed
35 unmodified lines
36fn set_git_revision_hash() {37 use std::process::Command;3839 let args = &["rev-parse", "--short=10", "HEAD"];40 let Ok(output) = Command::new("git").args(args).output() else { return };41 let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();42 if rev.is_empty() {43 return;40 let output = Command::new("git").args(args).output();41 match output {42 Ok(output) => {43 let rev =44 String::from_utf8_lossy(&output.stdout).trim().to_string();45 if rev.is_empty() {46 println!(47 "cargo:warning=output from `git rev-parse` is empty, \48 so skipping embedding of commit hash"49 );50 return;51 }52 println!("cargo:rustc-env=RIPGREP_BUILD_GIT_HASH={rev}");53 }54 Err(e) => {55 println!(56 "cargo:warning=failed to run `git rev-parse`, \57 so skipping embedding of commit hash: {e}"58 );59 }60 }45 println!("cargo:rustc-env=RIPGREP_BUILD_GIT_HASH={rev}");61}