mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-04 18:18:17 +00:00
Merge 7e5850d996
into 3b7fd442a6
This commit is contained in:
commit
e821746e97
1 changed files with 17 additions and 5 deletions
22
build.rs
22
build.rs
|
@ -37,10 +37,22 @@ fn set_git_revision_hash() {
|
|||
use std::process::Command;
|
||||
|
||||
let args = &["rev-parse", "--short=10", "HEAD"];
|
||||
let Ok(output) = Command::new("git").args(args).output() else { return };
|
||||
let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if rev.is_empty() {
|
||||
return;
|
||||
let output = Command::new("git").args(args).output();
|
||||
match output {
|
||||
Ok(output) => {
|
||||
let rev =
|
||||
String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if rev.is_empty() {
|
||||
return;
|
||||
}
|
||||
println!("cargo:rustc-env=RIPGREP_BUILD_GIT_HASH={}", rev);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
"cargo:warning=git not found, skipping commit hash embed (error: {}).",
|
||||
e
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
println!("cargo:rustc-env=RIPGREP_BUILD_GIT_HASH={}", rev);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue