From 320abe9b22bab6075ce2768b8daf57dc7311c5b0 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Wed, 16 Apr 2025 00:54:22 -0600 Subject: [PATCH] Agent Eval: Check if SHA already fetched (#28846) Release Notes: - N/A --- crates/eval/src/example.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/eval/src/example.rs b/crates/eval/src/example.rs index 8e7f6fc00688a9f84df2bc04d3db474e3ad54c08..0e0a385bcb55854e9a965f950e59026837753381 100644 --- a/crates/eval/src/example.rs +++ b/crates/eval/src/example.rs @@ -140,13 +140,21 @@ impl Example { pub async fn setup(&mut self) -> Result<()> { let repo_path = repo_path_for_url(&self.base.url); - println!("{}Fetching", self.log_prefix); - - run_git( - &repo_path, - &["fetch", "--depth", "1", "origin", &self.base.revision], - ) - .await?; + let revision_exists = run_git(&repo_path, &["rev-parse", "--verify", &self.base.revision]) + .await + .is_ok(); + + if !revision_exists { + println!( + "{}Fetching revision {}", + self.log_prefix, &self.base.revision + ); + run_git( + &repo_path, + &["fetch", "--depth", "1", "origin", &self.base.revision], + ) + .await?; + } let worktree_path = self.worktree_path();