feat(test.rs): Lookup the commit with cat-file to avoid re-fetches
This commit is contained in:
parent
452ebf5f37
commit
17e329777f
@ -511,6 +511,18 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
|
|||||||
Some(commit_hash) => commit_hash,
|
Some(commit_hash) => commit_hash,
|
||||||
None => return Err("Couldn't retrieve rustc commit hash".to_string()),
|
None => return Err("Couldn't retrieve rustc commit hash".to_string()),
|
||||||
};
|
};
|
||||||
|
let has_commit = {
|
||||||
|
if let Ok(ty) = run_command_with_env(
|
||||||
|
&[&"git", &"cat-file", &"-t", &rustc_commit.as_str()],
|
||||||
|
rust_dir,
|
||||||
|
Some(env),
|
||||||
|
) {
|
||||||
|
String::from_utf8_lossy(&ty.stdout).to_string() == "commit"
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if !has_commit {
|
||||||
run_command_with_output_and_env(
|
run_command_with_output_and_env(
|
||||||
&[
|
&[
|
||||||
&"git",
|
&"git",
|
||||||
@ -521,7 +533,8 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
|
|||||||
],
|
],
|
||||||
rust_dir,
|
rust_dir,
|
||||||
Some(env),
|
Some(env),
|
||||||
)?;
|
)?
|
||||||
|
};
|
||||||
if rustc_commit != "unknown" {
|
if rustc_commit != "unknown" {
|
||||||
run_command_with_output_and_env(
|
run_command_with_output_and_env(
|
||||||
&[&"git", &"checkout", &rustc_commit],
|
&[&"git", &"checkout", &rustc_commit],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user