Skip to content

Commit 6337896

Browse files
committed
Fix checking out rust directory if it does not exist
We need to clone it first, and then fetch the commit that we want to benchmark.
1 parent 1d98025 commit 6337896

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

collector/src/compile/execute/rustc.rs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -163,43 +163,44 @@ async fn record(
163163
}
164164

165165
fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> {
166-
if Path::new("rust").exists() {
167-
let mut status = Command::new("git")
168-
.current_dir("rust")
169-
.arg("fetch")
170-
.arg("origin")
171-
.arg(match artifact {
172-
ArtifactId::Commit(c) => c.sha.as_str(),
173-
ArtifactId::Tag(id) => id.as_str(),
174-
})
175-
.status()
176-
.context("git fetch origin")?;
177-
178-
if !status.success() {
179-
log::warn!(
180-
"git fetch origin {} failed, this will likely break the build",
181-
artifact
182-
);
183-
}
184-
185-
// Regardless, we fetch the default branch. Upstream Rust started using `git merge-base`
186-
// recently, which (reasonably) finds the wrong base if we think e.g. origin/master
187-
// diverged thousands of commits ago.
188-
status = Command::new("git")
189-
.current_dir("rust")
190-
.arg("fetch")
191-
.arg("origin")
192-
.arg("HEAD")
193-
.status()
194-
.context("git fetch origin HEAD")?;
195-
assert!(status.success(), "git fetch successful");
196-
} else {
166+
if !Path::new("rust").exists() {
197167
let status = Command::new("git")
198168
.arg("clone")
199169
.arg("https://github.com/rust-lang/rust")
200170
.status()
201171
.context("git clone")?;
202172
assert!(status.success(), "git clone successful");
203173
}
174+
175+
let mut status = Command::new("git")
176+
.current_dir("rust")
177+
.arg("fetch")
178+
.arg("origin")
179+
.arg(match artifact {
180+
ArtifactId::Commit(c) => c.sha.as_str(),
181+
ArtifactId::Tag(id) => id.as_str(),
182+
})
183+
.status()
184+
.context("git fetch origin")?;
185+
186+
if !status.success() {
187+
log::warn!(
188+
"git fetch origin {} failed, this will likely break the build",
189+
artifact
190+
);
191+
}
192+
193+
// Regardless, we fetch the default branch. Upstream Rust started using `git merge-base`
194+
// recently, which (reasonably) finds the wrong base if we think e.g. origin/master
195+
// diverged thousands of commits ago.
196+
status = Command::new("git")
197+
.current_dir("rust")
198+
.arg("fetch")
199+
.arg("origin")
200+
.arg("HEAD")
201+
.status()
202+
.context("git fetch origin HEAD")?;
203+
assert!(status.success(), "git fetch successful");
204+
204205
Ok(())
205206
}

0 commit comments

Comments
 (0)