Skip to content

Commit d794e1f

Browse files
committed
Auto merge of #12968 - ferrocene:pa-omit-git-hash, r=weihanglo
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.
2 parents 879c564 + ab76a0b commit d794e1f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ fn commit_info() {
5050
if !Path::new(".git").exists() {
5151
return;
5252
}
53+
54+
// Var set by bootstrap whenever omit-git-hash is enabled in rust-lang/rust's config.toml.
55+
println!("cargo:rerun-if-env-changed=CFG_OMIT_GIT_HASH");
56+
#[allow(clippy::disallowed_methods)]
57+
if std::env::var_os("CFG_OMIT_GIT_HASH").is_some() {
58+
return;
59+
}
60+
5361
let output = match Command::new("git")
5462
.arg("log")
5563
.arg("-1")

0 commit comments

Comments
 (0)