mirror of
https://github.com/stablyai/orca.git
synced 2026-10-01 16:02:03 +00:00
fix: identify partial-clone repositories from the correct remote (#23504)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user