Skip to content

Commit 79c8780

Browse files
Merge pull request #432 from tempdragon/master
Use shallow clone in test.rs to reduce cloning overhead
2 parents 3c6a265 + 17e3297 commit 79c8780

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

build_system/src/test.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,42 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
499499
&"clone",
500500
&"https://github.com/rust-lang/rust.git",
501501
&rust_dir_path,
502+
&"--depth",
503+
&"1",
502504
],
503505
None,
504506
Some(env),
505507
);
506508
let rust_dir: Option<&Path> = Some(&rust_dir_path);
507509
run_command(&[&"git", &"checkout", &"--", &"tests/"], rust_dir)?;
508-
run_command_with_output_and_env(&[&"git", &"fetch"], rust_dir, Some(env))?;
509510
let rustc_commit = match rustc_version_info(env.get("RUSTC").map(|s| s.as_str()))?.commit_hash {
510511
Some(commit_hash) => commit_hash,
511512
None => return Err("Couldn't retrieve rustc commit hash".to_string()),
512513
};
514+
let has_commit = {
515+
if let Ok(ty) = run_command_with_env(
516+
&[&"git", &"cat-file", &"-t", &rustc_commit.as_str()],
517+
rust_dir,
518+
Some(env),
519+
) {
520+
String::from_utf8_lossy(&ty.stdout).to_string() == "commit"
521+
} else {
522+
false
523+
}
524+
};
525+
if !has_commit {
526+
run_command_with_output_and_env(
527+
&[
528+
&"git",
529+
&"fetch",
530+
&"https://github.com/rust-lang/rust.git",
531+
&rustc_commit.as_str(),
532+
&"--depth=1",
533+
],
534+
rust_dir,
535+
Some(env),
536+
)?
537+
};
513538
if rustc_commit != "unknown" {
514539
run_command_with_output_and_env(
515540
&[&"git", &"checkout", &rustc_commit],

0 commit comments

Comments
 (0)