Skip to content

Commit 625e983

Browse files
committed
Make rustc checkout download optional
1 parent 1c550e3 commit 625e983

File tree

2 files changed

+22
-51
lines changed

2 files changed

+22
-51
lines changed

Cargo.lock

Lines changed: 0 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sync.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::SyncContext;
22
use crate::josh::JoshProxy;
3-
use crate::utils::ensure_clean_git_state;
43
use crate::utils::run_command;
54
use crate::utils::run_command_at;
5+
use crate::utils::{ensure_clean_git_state, prompt};
66
use anyhow::{Context, Error};
77
use std::path::{Path, PathBuf};
88

@@ -284,17 +284,27 @@ fn prepare_rustc_checkout() -> anyhow::Result<PathBuf> {
284284
// Otherwise, download it
285285
let path = "rustc-checkout";
286286
if !Path::new(path).join(".git").exists() {
287-
println!(
288-
"Cloning rustc into `{path}`. Use RUSTC_GIT environment variable to override the location of the checkout"
289-
);
290-
run_command(&[
291-
"git",
292-
"clone",
293-
"--filter=blob:none",
294-
"https://github.com/rust-lang/rust",
295-
path,
296-
])
297-
.context("cannot clone rustc")?;
287+
if prompt(
288+
&format!(
289+
"Path to a rustc checkout is not configured via the RUSTC_GIT environment variable, and {path} directory was not found. Do you want to download a rustc checkout into {path}?",
290+
),
291+
// Download git history if we are on CI
292+
true,
293+
) {
294+
println!(
295+
"Cloning rustc into `{path}`. Use RUSTC_GIT environment variable to override the location of the checkout"
296+
);
297+
run_command(&[
298+
"git",
299+
"clone",
300+
"--filter=blob:none",
301+
"https://github.com/rust-lang/rust",
302+
path,
303+
])
304+
.context("cannot clone rustc")?;
305+
} else {
306+
return Err(anyhow::anyhow!("cannot continue without a rustc checkout"));
307+
}
298308
}
299309
Ok(PathBuf::from(path))
300310
}

0 commit comments

Comments
 (0)