From c4cccba393518b19f8b2aadb23e48d4716680f23 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 2 Aug 2023 15:15:17 -0400 Subject: [PATCH 1/3] Fetch origin HEAD on checkout This ensures that git merge-base can find the right merge point; otherwise, our history looks to have diverged when the original checkout was made, which might be years ago. --- collector/src/compile/execute/rustc.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/collector/src/compile/execute/rustc.rs b/collector/src/compile/execute/rustc.rs index fda84320d..cb99e7c39 100644 --- a/collector/src/compile/execute/rustc.rs +++ b/collector/src/compile/execute/rustc.rs @@ -165,19 +165,23 @@ fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> { .status() .context("git fetch origin")?; - if !status.success() && matches!(artifact, ArtifactId::Tag(_)) { + if !status.success() { log::warn!( - "git fetch origin {} failed - trying default branch", + "git fetch origin {} failed, this will likely break the build", artifact ); - status = Command::new("git") - .current_dir("rust") - .arg("fetch") - .arg("origin") - .arg("HEAD") - .status() - .context("git fetch origin HEAD")?; } + + // Regardless, we fetch the default branch. Upstream Rust started using `git merge-base` + // recently, which (reasonably) finds the wrong base if we think e.g. origin/master + // diverged thousands of commits ago. + status = Command::new("git") + .current_dir("rust") + .arg("fetch") + .arg("origin") + .arg("HEAD") + .status() + .context("git fetch origin HEAD")?; assert!(status.success(), "git fetch successful"); } else { let status = Command::new("git") From f7bb6cda0b271d2b13779d5ab7adba2d2db9a330 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 31 Aug 2023 08:57:35 -0400 Subject: [PATCH 2/3] Fetch master branch directly --- collector/src/compile/execute/rustc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/src/compile/execute/rustc.rs b/collector/src/compile/execute/rustc.rs index cb99e7c39..89fb5ba4c 100644 --- a/collector/src/compile/execute/rustc.rs +++ b/collector/src/compile/execute/rustc.rs @@ -179,7 +179,7 @@ fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> { .current_dir("rust") .arg("fetch") .arg("origin") - .arg("HEAD") + .arg("master") .status() .context("git fetch origin HEAD")?; assert!(status.success(), "git fetch successful"); From 462582abc9877b0e3a831cee9e595766206b94b3 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 31 Aug 2023 09:23:34 -0400 Subject: [PATCH 3/3] Fix error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rémy Rakic --- collector/src/compile/execute/rustc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/src/compile/execute/rustc.rs b/collector/src/compile/execute/rustc.rs index 89fb5ba4c..49aec2a1a 100644 --- a/collector/src/compile/execute/rustc.rs +++ b/collector/src/compile/execute/rustc.rs @@ -181,7 +181,7 @@ fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> { .arg("origin") .arg("master") .status() - .context("git fetch origin HEAD")?; + .context("git fetch origin master")?; assert!(status.success(), "git fetch successful"); } else { let status = Command::new("git")