Skip to content

Commit dc34320

Browse files
committed
optimize
1 parent 7e73ef5 commit dc34320

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/bootstrap/src/core/build_steps/tool.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::path::PathBuf;
22
use std::{env, fs};
33

4-
use build_helper::git::get_closest_merge_commit;
5-
64
use crate::core::build_steps::compile;
75
use crate::core::build_steps::toolstate::ToolState;
86
use crate::core::builder;
@@ -596,19 +594,14 @@ impl Step for Rustdoc {
596594
&& target_compiler.stage > 0
597595
&& builder.rust_info().is_managed_git_subrepository()
598596
{
599-
let commit = get_closest_merge_commit(
600-
Some(&builder.config.src),
601-
&builder.config.git_config(),
602-
&[],
603-
)
604-
.unwrap();
605597

606-
let dirs = vec![
607-
builder.config.src.join("src/librustdoc"),
608-
builder.config.src.join("src/tools/rustdoc"),
598+
let files_to_track = &[
599+
"src/librustdoc",
600+
"src/tools/rustdoc",
609601
];
610-
let has_changes = builder.config.check_for_changes(&dirs, &commit);
611-
if !has_changes {
602+
603+
if builder.config.last_modified_commit(files_to_track, "rustdoc", true).is_some() {
604+
// if return Some(commit),means unchanged
612605
let precompiled_rustdoc = builder
613606
.config
614607
.ci_rustc_dir()

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

+14-3
Original file line numberDiff line numberDiff line change
@@ -2759,8 +2759,19 @@ impl Config {
27592759

27602760
// Look for a version to compare to based on the current commit.
27612761
// Only commits merged by bors will have CI artifacts.
2762-
let commit =
2763-
self.last_modified_commit(files_to_track, "download-rustc", if_unchanged).unwrap();
2762+
let commit = match self.last_modified_commit(files_to_track, "download-rustc", if_unchanged) {
2763+
Some(commit) => commit,
2764+
None => {
2765+
if if_unchanged{
2766+
return None;
2767+
}
2768+
println!("ERROR: could not find commit hash for downloading rustc");
2769+
println!("HELP: maybe your repository history is too shallow?");
2770+
println!("HELP: consider disabling `download-rustc`");
2771+
println!("HELP: or fetch enough history to include one upstream commit");
2772+
crate::exit!(1);
2773+
}
2774+
};
27642775

27652776
if CiEnv::is_ci() && {
27662777
let head_sha =
@@ -2775,7 +2786,7 @@ impl Config {
27752786
return None;
27762787
}
27772788

2778-
Some(commit.to_string())
2789+
Some(commit)
27792790
}
27802791

27812792
fn parse_download_ci_llvm(

0 commit comments

Comments
 (0)