From 254023a03c3aaa26e2d01c02f9b9933b82fd971e Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 19 Jun 2023 13:17:41 +0000 Subject: [PATCH] build: resolve benchmark compare ref from upstream if rev-parse fails `rev-parse` returns the original ref name in stdout, even if it wasn't able to resolve the reference. This was preventing the upstream resolution from never happening- causing `main` to be never resolved to the actual SHA. --- scripts/benchmarks/index.mts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/benchmarks/index.mts b/scripts/benchmarks/index.mts index 76f1c042117..df5c4a74b0d 100644 --- a/scripts/benchmarks/index.mts +++ b/scripts/benchmarks/index.mts @@ -97,8 +97,9 @@ async function prepareForGitHubAction(commentBody: string): Promise { // Attempt to find the compare SHA. The commit may be either part of the // pull request, or might be a commit unrelated to the PR- but part of the // upstream repository. We attempt to fetch/resolve the SHA in both remotes. - let compareRefSha = git.runGraceful(['rev-parse', compareRefRaw]).stdout.trim(); - if (compareRefSha === '') { + const compareRefResolve = git.runGraceful(['rev-parse', compareRefRaw]); + let compareRefSha = compareRefResolve.stdout.trim(); + if (compareRefSha === '' || compareRefResolve.status !== 0) { git.run(['fetch', '--depth=1', git.getRepoGitUrl(), compareRefRaw]); compareRefSha = git.run(['rev-parse', 'FETCH_HEAD']).stdout.trim(); }