about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-28 16:59:00 +0000
committerbors <bors@rust-lang.org>2021-07-28 16:59:00 +0000
commita28109a7679fbb254ca0962865a8b32b91ddbbd9 (patch)
tree288a796a8f64971fc536e644ffa067e421373c8d /src/bootstrap
parenteba3228b2a9875d268ff3990903d04e19f6cdb0c (diff)
parent7985e4c7c3fb9c1a4f09f1c24949f21e65ceee37 (diff)
downloadrust-a28109a7679fbb254ca0962865a8b32b91ddbbd9.tar.gz
rust-a28109a7679fbb254ca0962865a8b32b91ddbbd9.zip
Auto merge of #87540 - JohnTitor:rollup-8xc6bl5, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #87315 (Add docs for raw-dylib to unstable book)
 - #87330 (Use hashbrown's `extend_reserve()` in `HashMap`)
 - #87443 (Don't treat git repos as non-existent when `ignore_git` is set)
 - #87453 (Suggest removing unnecessary &mut as help message)
 - #87500 (Document math behind MIN/MAX consts on integers)
 - #87501 (Remove min_type_alias_impl_trait in favor of type_alias_impl_trait)
 - #87507 (SGX mutex is *not* moveable)
 - #87513 (bootstrap.py: change `git log` option to indicate desired behavior)
 - #87523 (Stop creating a reference then immediately dereferencing it.)
 - #87524 (Fix ICE in `diagnostic_hir_wf_check`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/bootstrap.py2
-rw-r--r--src/bootstrap/channel.rs53
-rw-r--r--src/bootstrap/lib.rs2
3 files changed, 38 insertions, 19 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index d2cf929aa26..f2e38a7eab6 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -473,7 +473,7 @@ class RustBuild(object):
             ]).decode(sys.getdefaultencoding()).strip()
             llvm_sha = subprocess.check_output([
                 "git", "log", "--author=bors", "--format=%H", "-n1",
-                "-m", "--first-parent",
+                "--no-patch", "--first-parent",
                 "--",
                 "{}/src/llvm-project".format(top_level),
                 "{}/src/bootstrap/download-ci-llvm-stamp".format(top_level),
diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs
index 6e65be93fec..6478578c3c4 100644
--- a/src/bootstrap/channel.rs
+++ b/src/bootstrap/channel.rs
@@ -12,11 +12,16 @@ use build_helper::output;
 
 use crate::Build;
 
-pub struct GitInfo {
-    inner: Option<Info>,
+pub enum GitInfo {
+    /// This is not a git repository.
+    Absent,
+    /// This is a git repository.
+    /// If the info should be used (`ignore_git` is false), this will be
+    /// `Some`, otherwise it will be `None`.
+    Present(Option<Info>),
 }
 
-struct Info {
+pub struct Info {
     commit_date: String,
     sha: String,
     short_sha: String,
@@ -25,14 +30,20 @@ struct Info {
 impl GitInfo {
     pub fn new(ignore_git: bool, dir: &Path) -> GitInfo {
         // See if this even begins to look like a git dir
-        if ignore_git || !dir.join(".git").exists() {
-            return GitInfo { inner: None };
+        if !dir.join(".git").exists() {
+            return GitInfo::Absent;
         }
 
         // Make sure git commands work
         match Command::new("git").arg("rev-parse").current_dir(dir).output() {
             Ok(ref out) if out.status.success() => {}
-            _ => return GitInfo { inner: None },
+            _ => return GitInfo::Absent,
+        }
+
+        // If we're ignoring the git info, we don't actually need to collect it, just make sure this
+        // was a git repo in the first place.
+        if ignore_git {
+            return GitInfo::Present(None);
         }
 
         // Ok, let's scrape some info
@@ -48,30 +59,35 @@ impl GitInfo {
         let short_ver_hash = output(
             Command::new("git").current_dir(dir).arg("rev-parse").arg("--short=9").arg("HEAD"),
         );
-        GitInfo {
-            inner: Some(Info {
-                commit_date: ver_date.trim().to_string(),
-                sha: ver_hash.trim().to_string(),
-                short_sha: short_ver_hash.trim().to_string(),
-            }),
+        GitInfo::Present(Some(Info {
+            commit_date: ver_date.trim().to_string(),
+            sha: ver_hash.trim().to_string(),
+            short_sha: short_ver_hash.trim().to_string(),
+        }))
+    }
+
+    fn info(&self) -> Option<&Info> {
+        match self {
+            GitInfo::Present(info) => info.as_ref(),
+            GitInfo::Absent => None,
         }
     }
 
     pub fn sha(&self) -> Option<&str> {
-        self.inner.as_ref().map(|s| &s.sha[..])
+        self.info().map(|s| &s.sha[..])
     }
 
     pub fn sha_short(&self) -> Option<&str> {
-        self.inner.as_ref().map(|s| &s.short_sha[..])
+        self.info().map(|s| &s.short_sha[..])
     }
 
     pub fn commit_date(&self) -> Option<&str> {
-        self.inner.as_ref().map(|s| &s.commit_date[..])
+        self.info().map(|s| &s.commit_date[..])
     }
 
     pub fn version(&self, build: &Build, num: &str) -> String {
         let mut version = build.release(num);
-        if let Some(ref inner) = self.inner {
+        if let Some(ref inner) = self.info() {
             version.push_str(" (");
             version.push_str(&inner.short_sha);
             version.push(' ');
@@ -82,6 +98,9 @@ impl GitInfo {
     }
 
     pub fn is_git(&self) -> bool {
-        self.inner.is_some()
+        match self {
+            GitInfo::Absent => false,
+            GitInfo::Present(_) => true,
+        }
     }
 }
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 245f3eada2a..3d56650f775 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1145,7 +1145,7 @@ impl Build {
         match &self.config.channel[..] {
             "stable" => num.to_string(),
             "beta" => {
-                if self.rust_info.is_git() {
+                if self.rust_info.is_git() && !self.config.ignore_git {
                     format!("{}-beta.{}", num, self.beta_prerelease_version())
                 } else {
                     format!("{}-beta", num)