From 12597428658fc7b72244e8717d0ca6fc83fca11c Mon Sep 17 00:00:00 2001 From: Hudson Ayers Date: Tue, 27 Jul 2021 13:54:51 +0000 Subject: [PATCH 1/3] bootstrap.py: remove unused `git log` option When determining which LLVM artifacts to download, bootstrap.py calls: `git log --author=bors --format=%H -n1 -m --first-parent -- src/llvm-project src/bootstrap/download-ci-llvm-stamp src/version`. However, the `-m` option has no effect, per the `git log` help: > -m > This option makes diff output for merge commits to be shown in the > default format. -m will produce the output only if -p is given as > well. The default format could be changed using log.diffMerges > configuration parameter, which default value is separate. Accordingly, this commit removes use of the -m option in favor of `--no-patch`, to make clear that this command should never output diff information, as the SHA-1 hash is the only desired output. Tested using git 2.32, this does not change the output of the command. The motivation for this change is that some patched versions of git change the behavior of the `-m` flag to imply `-p`, rather than to do nothing unless `-p` is passed. These patched versions of git lead to this script not working. Google's corp-provided git is one such example. --- src/bootstrap/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index d2cf929aa266f..f2e38a7eab6bc 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -473,7 +473,7 @@ def download_toolchain(self, stage0=True, rustc_channel=None): ]).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), From 5d285206adf191d1aa3eb46be18d6e1dd32f8847 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Tue, 27 Jul 2021 18:14:37 -0500 Subject: [PATCH 2/3] bootstrap.py: use `git rev-list` for robustness Use `git rev-list` instead of `git log` to be more robust against UI changes in git. Also, use the full email address for bors, because `--author` uses a substring match. --- src/bootstrap/bootstrap.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index f2e38a7eab6bc..41d88950ef999 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -464,7 +464,8 @@ def download_toolchain(self, stage0=True, rustc_channel=None): # LLVM more often than necessary. # # This git command finds that commit SHA, looking for bors-authored - # merges that modified src/llvm-project. + # commits that modified src/llvm-project or other relevant version + # stamp files. # # This works even in a repository that has not yet initialized # submodules. @@ -472,8 +473,8 @@ def download_toolchain(self, stage0=True, rustc_channel=None): "git", "rev-parse", "--show-toplevel", ]).decode(sys.getdefaultencoding()).strip() llvm_sha = subprocess.check_output([ - "git", "log", "--author=bors", "--format=%H", "-n1", - "--no-patch", "--first-parent", + "git", "rev-list", "--author=bors@rust-lang.org", "-n1", + "--first-parent", "HEAD", "--", "{}/src/llvm-project".format(top_level), "{}/src/bootstrap/download-ci-llvm-stamp".format(top_level), @@ -665,7 +666,7 @@ def maybe_download_ci_toolchain(self): # Look for a version to compare to based on the current commit. # Only commits merged by bors will have CI artifacts. - merge_base = ["git", "log", "--author=bors", "--pretty=%H", "-n1"] + merge_base = ["git", "rev-list", "--author=bors@rust-lang.org", "-n1", "HEAD"] commit = subprocess.check_output(merge_base, universal_newlines=True).strip() # Warn if there were changes to the compiler or standard library since the ancestor commit. From e0d7a591a52da064727e4ae143ef6ae1364c5d02 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Tue, 27 Jul 2021 19:58:16 -0500 Subject: [PATCH 3/3] boostrap.py: only look for merges by bors Only look for commits by bors that are merge commits, because those are the only ones with CI artifacts. Also, use `--first-parent` to avoid traversing stuff like rollup branches. --- src/bootstrap/bootstrap.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 41d88950ef999..3faf38c66ec8b 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -464,7 +464,7 @@ def download_toolchain(self, stage0=True, rustc_channel=None): # LLVM more often than necessary. # # This git command finds that commit SHA, looking for bors-authored - # commits that modified src/llvm-project or other relevant version + # merges that modified src/llvm-project or other relevant version # stamp files. # # This works even in a repository that has not yet initialized @@ -474,7 +474,7 @@ def download_toolchain(self, stage0=True, rustc_channel=None): ]).decode(sys.getdefaultencoding()).strip() llvm_sha = subprocess.check_output([ "git", "rev-list", "--author=bors@rust-lang.org", "-n1", - "--first-parent", "HEAD", + "--merges", "--first-parent", "HEAD", "--", "{}/src/llvm-project".format(top_level), "{}/src/bootstrap/download-ci-llvm-stamp".format(top_level), @@ -666,7 +666,10 @@ def maybe_download_ci_toolchain(self): # Look for a version to compare to based on the current commit. # Only commits merged by bors will have CI artifacts. - merge_base = ["git", "rev-list", "--author=bors@rust-lang.org", "-n1", "HEAD"] + merge_base = [ + "git", "rev-list", "--author=bors@rust-lang.org", "-n1", + "--merges", "--first-parent", "HEAD" + ] commit = subprocess.check_output(merge_base, universal_newlines=True).strip() # Warn if there were changes to the compiler or standard library since the ancestor commit.