use download-rustc="if-unchanged" as default whenever possible

"whenever possible" means applying it if `download-rustc` isn't explicitly set and
the source is Git-managed.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2024-11-08 16:23:59 +03:00
parent 76b6090df5
commit cce6f03754

View File

@ -2756,9 +2756,19 @@ fn download_ci_rustc_commit(
// If `download-rustc` is not set, default to rebuilding.
let if_unchanged = match download_rustc {
None | Some(StringOrBool::Bool(false)) => return None,
None => self.rust_info.is_managed_git_subrepository(),
Some(StringOrBool::Bool(false)) => return None,
Some(StringOrBool::Bool(true)) => false,
Some(StringOrBool::String(s)) if s == "if-unchanged" => true,
Some(StringOrBool::String(s)) if s == "if-unchanged" => {
if !self.rust_info.is_managed_git_subrepository() {
println!(
"ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources."
);
crate::exit!(1);
}
true
}
Some(StringOrBool::String(other)) => {
panic!("unrecognized option for download-rustc: {other}")
}
@ -2785,7 +2795,7 @@ fn download_ci_rustc_commit(
}
println!("ERROR: could not find commit hash for downloading rustc");
println!("HELP: maybe your repository history is too shallow?");
println!("HELP: consider disabling `download-rustc`");
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
println!("HELP: or fetch enough history to include one upstream commit");
crate::exit!(1);
}