Skip to content

Commit

Permalink
Fetch origin master on checkout (#1684)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mark-Simulacrum authored Aug 31, 2023
1 parent 1744325 commit 4393fa0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions collector/src/compile/execute/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("master")
.status()
.context("git fetch origin master")?;
assert!(status.success(), "git fetch successful");
} else {
let status = Command::new("git")
Expand Down

0 comments on commit 4393fa0

Please sign in to comment.