From 9412fd7371bfb8cc8e6b20240b84168a88ac9d21 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 4 Sep 2017 16:29:57 +0200 Subject: [PATCH] Only include git-commit-hash in tarballs when available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … instead of writing an empty file. --- src/bootstrap/dist.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 07ef043072096..2920b91b25530 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -364,9 +364,10 @@ impl Step for Rustc { cp("README.md"); // tiny morsel of metadata is used by rust-packaging let version = build.rust_version(); - let sha = build.rust_sha().unwrap_or(""); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); - t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + if let Some(sha) = build.rust_sha() { + t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + } // On MinGW we've got a few runtime DLL dependencies that we need to // include. The first argument to this script is where to put these DLLs @@ -846,8 +847,9 @@ impl Step for PlainSourceTarball { // Create the version file write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes()); - let sha = build.rust_sha().unwrap_or(""); - write_file(&plain_dst_src.join("git-commit-hash"), sha.as_bytes()); + if let Some(sha) = build.rust_sha() { + write_file(&plain_dst_src.join("git-commit-hash"), sha.as_bytes()); + } // If we're building from git sources, we need to vendor a complete distribution. if build.rust_info.is_git() { @@ -1160,9 +1162,10 @@ impl Step for Extended { install(&build.src.join("LICENSE-APACHE"), &overlay, 0o644); install(&build.src.join("LICENSE-MIT"), &overlay, 0o644); let version = build.rust_version(); - let sha = build.rust_sha().unwrap_or(""); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); - t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + if let Some(sha) = build.rust_sha() { + t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + } install(&etc.join("README.md"), &overlay, 0o644); // When rust-std package split from rustc, we needed to ensure that during