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 }