fix: identify partial-clone repositories from the correct remote (#23504)

This commit is contained in:
Neil
2026-09-27 18:05:13 -07:00
committed by GitHub
parent 6c56c0a3dc
commit dd90b3183f
2 changed files with 21 additions and 4 deletions
+19
View File
@@ -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(
+2 -4
View File
@@ -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
}