Skip to content

Commit 4aec8a5

Browse files
committed
Use log --author=bors instead of merge-base
1 parent 6457845 commit 4aec8a5

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

src/bootstrap/bootstrap.py

+9-25
Original file line numberDiff line numberDiff line change
@@ -637,35 +637,19 @@ def maybe_download_rustc(self):
637637
# If `download-rustc` is not set, default to rebuilding.
638638
if self.get_toml("download-rustc", section="rust") != "true":
639639
return None
640-
# Look for a version to compare to based on the current commit.
641-
# There are a few different cases to handle.
642-
# 1. This commit is a fast-forward from master: `master - * - * - HEAD`
643-
# 2. This commit and master have diverged:
644-
# ```
645-
# Y - * - HEAD
646-
# /
647-
# X - * - master
648-
# ```
649-
# In this case, we should compare to `X`.
650-
# 3. `master` and `HEAD` are radically different (>100 commits, or similar). This probably
651-
# means that `master` does *not* correspond to the version we want to compare to, e.g. a
652-
# fork. Instead, we want to compare to `rust-lang/rust:master`, which this has to share a
653-
# recent merge base with.
654-
655-
# Find which remote corresponds to `rust-lang/rust`.
656-
remotes = subprocess.check_output(["git", "remote", "-v"], universal_newlines=True)
657-
# e.g. `origin https://github.com//rust-lang/rust (fetch)`
658-
rust_lang_remote = next(line for line in remotes.splitlines() if "rust-lang/rust" in line)
659-
rust_lang_remote = rust_lang_remote.split()[0]
660-
661-
# Find which commit to compare to
662-
merge_base = ["git", "merge-base", "HEAD", "{}/master".format(rust_lang_remote)]
663-
commit = subprocess.check_output(merge_base, universal_newlines=True).strip()
664640

665-
# Warn if there were changes to the compiler since the ancestor commit.
641+
# Handle running from a directory other than the top level
666642
rev_parse = ["git", "rev-parse", "--show-toplevel"]
667643
top_level = subprocess.check_output(rev_parse, universal_newlines=True).strip()
668644
compiler = "{}/compiler/".format(top_level)
645+
646+
# Look for a version to compare to based on the current commit.
647+
# Ideally this would just use `merge-base`, but on beta and stable branches that wouldn't
648+
# come up with any commits, so hack it and use `author=bors` instead.
649+
merge_base = ["git", "log", "--author=bors", "--pretty=%H", "-n1", "--", compiler]
650+
commit = subprocess.check_output(merge_base, universal_newlines=True).strip()
651+
652+
# Warn if there were changes to the compiler since the ancestor commit.
669653
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler])
670654
if status != 0:
671655
print("warning: `download-rustc` is enabled, but there are changes to compiler/")

0 commit comments

Comments
 (0)