diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-01-20 12:37:54 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-20 12:37:54 +0800 |
| commit | afdf3aa45794498a3b9f540168f7ee13bdaf8e42 (patch) | |
| tree | aa3063a76596cd67b710c83ae2fc1baf420bf10c /src/bootstrap | |
| parent | 6db2d1aae5d74f57f5218bcf6c839f2e653f1ac2 (diff) | |
| parent | 903cddb392bc9a5bc43194bcbb8b031f2fcc2c56 (diff) | |
| download | rust-afdf3aa45794498a3b9f540168f7ee13bdaf8e42.tar.gz rust-afdf3aa45794498a3b9f540168f7ee13bdaf8e42.zip | |
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.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 1c49063ef5c..b5310108dbf 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2875,21 +2875,26 @@ impl Config { allowed_paths.push(":!library"); } - // Look for a version to compare to based on the current commit. - // Only commits merged by bors will have CI artifacts. - let commit = match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged) - { - Some(commit) => commit, - None => { - if if_unchanged { - return None; + let commit = if self.rust_info.is_managed_git_subrepository() { + // Look for a version to compare to based on the current commit. + // Only commits merged by bors will have CI artifacts. + match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged) { + Some(commit) => commit, + None => { + if if_unchanged { + return None; + } + println!("ERROR: could not find commit hash for downloading rustc"); + println!("HELP: maybe your repository history is too shallow?"); + 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); } - println!("ERROR: could not find commit hash for downloading rustc"); - println!("HELP: maybe your repository history is too shallow?"); - 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); } + } else { + channel::read_commit_info_file(&self.src) + .map(|info| info.sha.trim().to_owned()) + .expect("git-commit-info is missing in the project root") }; if CiEnv::is_ci() && { @@ -2971,6 +2976,11 @@ impl Config { option_name: &str, if_unchanged: bool, ) -> Option<String> { + assert!( + self.rust_info.is_managed_git_subrepository(), + "Can't run `Config::last_modified_commit` on a non-git source." + ); + // Look for a version to compare to based on the current commit. // Only commits merged by bors will have CI artifacts. let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap(); |
