fix: fetch only specific PR ref instead of all PR refs

The previous implementation fetched ALL PR refs with:
  git fetch origin +refs/pull/*:refs/remotes/origin/pull/*

This is extremely slow for repos with many PRs (700+ PRs in unity-builder).
Now fetches only the specific PR ref needed, e.g., for pull/731/merge:
  git fetch origin +refs/pull/731/merge:... +refs/pull/731/head:...

This should significantly speed up the Cloud Runner integrity tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
frostebite
2026-01-30 00:52:04 +00:00
parent b5b1382daf
commit 88941c4022
3 changed files with 33 additions and 9 deletions

18
dist/index.js generated vendored
View File

@@ -6856,8 +6856,13 @@ class RemoteClient {
remote_client_logger_1.RemoteClientLogger.log(`${cloud_runner_1.default.buildParameters.branch}`);
// Ensure refs exist (tags and PR refs)
await cloud_runner_system_1.CloudRunnerSystem.Run(`git fetch --all --tags || true`);
if ((cloud_runner_1.default.buildParameters.branch || '').startsWith('pull/')) {
await cloud_runner_system_1.CloudRunnerSystem.Run(`git fetch origin +refs/pull/*:refs/remotes/origin/pull/* || true`);
const branchForPrFetch = cloud_runner_1.default.buildParameters.branch || '';
if (branchForPrFetch.startsWith('pull/')) {
// Extract PR number and fetch only that specific ref (e.g., pull/731/merge -> 731)
const prNumber = branchForPrFetch.split('/')[1];
if (prNumber) {
await cloud_runner_system_1.CloudRunnerSystem.Run(`git fetch origin +refs/pull/${prNumber}/merge:refs/remotes/origin/pull/${prNumber}/merge +refs/pull/${prNumber}/head:refs/remotes/origin/pull/${prNumber}/head || true`);
}
}
const targetSha = cloud_runner_1.default.buildParameters.gitSha;
const targetBranch = cloud_runner_1.default.buildParameters.branch;
@@ -6983,8 +6988,13 @@ class RemoteClient {
cloud_runner_logger_1.default.log(`Retained Workspace Already Exists!`);
process.chdir(cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute));
await cloud_runner_system_1.CloudRunnerSystem.Run(`git fetch --all --tags || true`);
if ((cloud_runner_1.default.buildParameters.branch || '').startsWith('pull/')) {
await cloud_runner_system_1.CloudRunnerSystem.Run(`git fetch origin +refs/pull/*:refs/remotes/origin/pull/* || true`);
const retainedBranchForPrFetch = cloud_runner_1.default.buildParameters.branch || '';
if (retainedBranchForPrFetch.startsWith('pull/')) {
// Extract PR number and fetch only that specific ref (e.g., pull/731/merge -> 731)
const prNumber = retainedBranchForPrFetch.split('/')[1];
if (prNumber) {
await cloud_runner_system_1.CloudRunnerSystem.Run(`git fetch origin +refs/pull/${prNumber}/merge:refs/remotes/origin/pull/${prNumber}/merge +refs/pull/${prNumber}/head:refs/remotes/origin/pull/${prNumber}/head || true`);
}
}
await cloud_runner_system_1.CloudRunnerSystem.Run(`git lfs pull`);
await cloud_runner_system_1.CloudRunnerSystem.Run(`git lfs checkout || true`);

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -322,8 +322,15 @@ export class RemoteClient {
// Ensure refs exist (tags and PR refs)
await CloudRunnerSystem.Run(`git fetch --all --tags || true`);
if ((CloudRunner.buildParameters.branch || '').startsWith('pull/')) {
await CloudRunnerSystem.Run(`git fetch origin +refs/pull/*:refs/remotes/origin/pull/* || true`);
const branchForPrFetch = CloudRunner.buildParameters.branch || '';
if (branchForPrFetch.startsWith('pull/')) {
// Extract PR number and fetch only that specific ref (e.g., pull/731/merge -> 731)
const prNumber = branchForPrFetch.split('/')[1];
if (prNumber) {
await CloudRunnerSystem.Run(
`git fetch origin +refs/pull/${prNumber}/merge:refs/remotes/origin/pull/${prNumber}/merge +refs/pull/${prNumber}/head:refs/remotes/origin/pull/${prNumber}/head || true`,
);
}
}
const targetSha = CloudRunner.buildParameters.gitSha;
const targetBranch = CloudRunner.buildParameters.branch;
@@ -459,8 +466,15 @@ export class RemoteClient {
CloudRunnerLogger.log(`Retained Workspace Already Exists!`);
process.chdir(CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.repoPathAbsolute));
await CloudRunnerSystem.Run(`git fetch --all --tags || true`);
if ((CloudRunner.buildParameters.branch || '').startsWith('pull/')) {
await CloudRunnerSystem.Run(`git fetch origin +refs/pull/*:refs/remotes/origin/pull/* || true`);
const retainedBranchForPrFetch = CloudRunner.buildParameters.branch || '';
if (retainedBranchForPrFetch.startsWith('pull/')) {
// Extract PR number and fetch only that specific ref (e.g., pull/731/merge -> 731)
const prNumber = retainedBranchForPrFetch.split('/')[1];
if (prNumber) {
await CloudRunnerSystem.Run(
`git fetch origin +refs/pull/${prNumber}/merge:refs/remotes/origin/pull/${prNumber}/merge +refs/pull/${prNumber}/head:refs/remotes/origin/pull/${prNumber}/head || true`,
);
}
}
await CloudRunnerSystem.Run(`git lfs pull`);
await CloudRunnerSystem.Run(`git lfs checkout || true`);