Skip to content

Commit afdf3aa

Browse files
authored
Rollup merge of #135722 - onur-ozkan:handle-tarball-ci-commit, r=jieyouxu
make it possible to use ci-rustc on tarball sources Previously, bootstrap was using `Config::last_modified_commit` unconditionally to figure the commit to download precompiled rustc artifact from CI, which was leading builds to fail on tarball sources as `Config::last_modified_commit` requires `git` to be present in the project source. This change makes bootstrap to call `Config::last_modified_commit` only when it's running on git-managed source and read `git-commit-hash` file otherwise.
2 parents 6db2d1a + 903cddb commit afdf3aa

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/bootstrap/src/core/config/config.rs

+23-13
Original file line numberDiff line numberDiff line change
@@ -2875,21 +2875,26 @@ impl Config {
28752875
allowed_paths.push(":!library");
28762876
}
28772877

2878-
// Look for a version to compare to based on the current commit.
2879-
// Only commits merged by bors will have CI artifacts.
2880-
let commit = match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged)
2881-
{
2882-
Some(commit) => commit,
2883-
None => {
2884-
if if_unchanged {
2885-
return None;
2878+
let commit = if self.rust_info.is_managed_git_subrepository() {
2879+
// Look for a version to compare to based on the current commit.
2880+
// Only commits merged by bors will have CI artifacts.
2881+
match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged) {
2882+
Some(commit) => commit,
2883+
None => {
2884+
if if_unchanged {
2885+
return None;
2886+
}
2887+
println!("ERROR: could not find commit hash for downloading rustc");
2888+
println!("HELP: maybe your repository history is too shallow?");
2889+
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2890+
println!("HELP: or fetch enough history to include one upstream commit");
2891+
crate::exit!(1);
28862892
}
2887-
println!("ERROR: could not find commit hash for downloading rustc");
2888-
println!("HELP: maybe your repository history is too shallow?");
2889-
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2890-
println!("HELP: or fetch enough history to include one upstream commit");
2891-
crate::exit!(1);
28922893
}
2894+
} else {
2895+
channel::read_commit_info_file(&self.src)
2896+
.map(|info| info.sha.trim().to_owned())
2897+
.expect("git-commit-info is missing in the project root")
28932898
};
28942899

28952900
if CiEnv::is_ci() && {
@@ -2971,6 +2976,11 @@ impl Config {
29712976
option_name: &str,
29722977
if_unchanged: bool,
29732978
) -> Option<String> {
2979+
assert!(
2980+
self.rust_info.is_managed_git_subrepository(),
2981+
"Can't run `Config::last_modified_commit` on a non-git source."
2982+
);
2983+
29742984
// Look for a version to compare to based on the current commit.
29752985
// Only commits merged by bors will have CI artifacts.
29762986
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();

0 commit comments

Comments
 (0)