eval: Fix git revision existence check (#28959)

This change fixes a bug in the worktree initialization.

Details: `git ref-parse --verify $HASH` just checks that $HASH is a
well-formed hash and will successfully return even if $HASH doesn't
exist.

Release Notes:

- N/A
This commit is contained in:
Oleksiy Syvokon 2025-04-17 19:57:37 +03:00 committed by GitHub
parent e7afbbd725
commit 6dd622d6c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -140,9 +140,12 @@ impl Example {
pub async fn setup(&mut self) -> Result<()> {
let repo_path = repo_path_for_url(&self.base.url);
let revision_exists = run_git(&repo_path, &["rev-parse", "--verify", &self.base.revision])
.await
.is_ok();
let revision_exists = run_git(
&repo_path,
&["rev-parse", &format!("{}^{{commit}}", self.base.revision)],
)
.await
.is_ok();
if !revision_exists {
println!(