From dd90b3183fc6a729dedf28caade6af01293fce13 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 27 Sep 2026 18:05:13 -0700 Subject: [PATCH] fix: identify partial-clone repositories from the correct remote (#23504) --- src/shared/git-remote-identity.test.ts | 19 +++++++++++++++++++ src/shared/git-remote-identity.ts | 6 ++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/shared/git-remote-identity.test.ts b/src/shared/git-remote-identity.test.ts index cc4fa4dff57..a159f5d39d9 100644 --- a/src/shared/git-remote-identity.test.ts +++ b/src/shared/git-remote-identity.test.ts @@ -51,6 +51,25 @@ describe('normalizeGitRemoteUrl', () => { }) describe('deriveGitRemoteIdentity', () => { + it.each(['blob:none', 'blob:limit=1024', 'tree:0'])( + 'prefers a partial-clone origin with filter %s over contributor remotes', + (filter) => { + expect( + deriveGitRemoteIdentity( + [ + 'amoaba\thttps://github.com/AmoabaKelvin/orca.git (fetch)', + `origin\thttps://github.com/stablyai/orca.git (fetch) [${filter}]`, + 'origin\thttps://github.com/another/orca.git (push)' + ].join('\r\n') + ) + ).toEqual({ + canonicalKey: 'github.com/stablyai/orca', + remoteName: 'origin', + remoteUrl: 'https://github.com/stablyai/orca.git' + }) + } + ) + it('prefers upstream, then origin, then the first named remote', () => { expect( deriveGitRemoteIdentity( diff --git a/src/shared/git-remote-identity.ts b/src/shared/git-remote-identity.ts index bc221157a2e..c4c215e125d 100644 --- a/src/shared/git-remote-identity.ts +++ b/src/shared/git-remote-identity.ts @@ -95,10 +95,8 @@ export function parseGitRemoteVerboseOutput(stdout: string): GitRemoteEntry[] { const entries: GitRemoteEntry[] = [] for (const rawLine of stdout.split(/\r?\n/)) { const line = rawLine.trim() - if (!line.endsWith('(fetch)')) { - continue - } - const match = /^(\S+)\s+(.+?)\s+\(fetch\)$/.exec(line) + // Partial clones append their object filter after the fetch marker. + const match = /^(\S+)\s+(.+?)\s+\(fetch\)(?:\s+\[[^\]\r\n]*\])?$/.exec(line) if (!match) { continue }