Skip to content

Commit 9412fd7

Browse files
committed
Only include git-commit-hash in tarballs when available
… instead of writing an empty file.
1 parent 9abc549 commit 9412fd7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/bootstrap/dist.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,10 @@ impl Step for Rustc {
364364
cp("README.md");
365365
// tiny morsel of metadata is used by rust-packaging
366366
let version = build.rust_version();
367-
let sha = build.rust_sha().unwrap_or("");
368367
t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes()));
369-
t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes()));
368+
if let Some(sha) = build.rust_sha() {
369+
t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes()));
370+
}
370371

371372
// On MinGW we've got a few runtime DLL dependencies that we need to
372373
// include. The first argument to this script is where to put these DLLs
@@ -846,8 +847,9 @@ impl Step for PlainSourceTarball {
846847

847848
// Create the version file
848849
write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes());
849-
let sha = build.rust_sha().unwrap_or("");
850-
write_file(&plain_dst_src.join("git-commit-hash"), sha.as_bytes());
850+
if let Some(sha) = build.rust_sha() {
851+
write_file(&plain_dst_src.join("git-commit-hash"), sha.as_bytes());
852+
}
851853

852854
// If we're building from git sources, we need to vendor a complete distribution.
853855
if build.rust_info.is_git() {
@@ -1160,9 +1162,10 @@ impl Step for Extended {
11601162
install(&build.src.join("LICENSE-APACHE"), &overlay, 0o644);
11611163
install(&build.src.join("LICENSE-MIT"), &overlay, 0o644);
11621164
let version = build.rust_version();
1163-
let sha = build.rust_sha().unwrap_or("");
11641165
t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes()));
1165-
t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes()));
1166+
if let Some(sha) = build.rust_sha() {
1167+
t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes()));
1168+
}
11661169
install(&etc.join("README.md"), &overlay, 0o644);
11671170

11681171
// When rust-std package split from rustc, we needed to ensure that during

0 commit comments

Comments
 (0)