perf(git): skip malformed remote base probes

This commit is contained in:
Neil
2026-09-05 06:13:12 -07:00
parent 9d88718170
commit 5e2e2e1951
2 changed files with 12 additions and 3 deletions
+11 -2
View File
@@ -176,8 +176,17 @@ describe('OrcaRuntimeService.fetchRemoteWithCache', () => {
expect(caches.fetchLastCompletedAt.has('/repo/cache-0::origin')).toBe(false)
})
it.each(['main', 'a'.repeat(40), 'refs/remotes/main', ''])(
'does not launch Git for a base without a remote/branch separator: %s',
it.each([
'main',
'a'.repeat(40),
'refs/remotes/main',
'',
'origin/',
'/main',
'refs/remotes/origin/',
'refs/remotes//main'
])(
'does not launch Git for a base without both remote and branch components: %s',
async (base) => {
const runtime = new OrcaRuntimeService(null)
await expect(runtime.resolveRemoteTrackingBase('/repo/e', base)).resolves.toBeNull()
@@ -231,7 +231,7 @@ export class RuntimeRemoteFetchController {
? baseBranch.slice(remoteRefPrefix.length)
: baseBranch
// A remote-tracking base needs both a configured remote and a branch component.
if (!shortBaseBranch.includes('/')) {
if (shortBaseBranch.indexOf('/') <= 0 || shortBaseBranch.endsWith('/')) {
return null
}
let remotes: string[]