Skip to content

Commit

Permalink
Auto merge of rust-lang#12968 - ferrocene:pa-omit-git-hash, r=weihanglo
Browse files Browse the repository at this point in the history
Respect `rust-lang/rust`'s `omit-git-hash`

The `config.toml` file in `rust-lang/rust` has the `omit-git-hash` option, which prevents git information from being embedded into binaries. This works for most tools, as they rely on the git information provided by bootstrap through environment variables.

Cargo does its own git detection in its build script though, which didn't adhere to to that option. This changes that by skipping git detection whenever bootstrap signals the option is enabled.
  • Loading branch information
bors committed Nov 19, 2023
2 parents 879c564 + ab76a0b commit d794e1f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ fn commit_info() {
if !Path::new(".git").exists() {
return;
}

// Var set by bootstrap whenever omit-git-hash is enabled in rust-lang/rust's config.toml.
println!("cargo:rerun-if-env-changed=CFG_OMIT_GIT_HASH");
#[allow(clippy::disallowed_methods)]
if std::env::var_os("CFG_OMIT_GIT_HASH").is_some() {
return;
}

let output = match Command::new("git")
.arg("log")
.arg("-1")
Expand Down

0 comments on commit d794e1f

Please sign in to comment.