1128
/** Returns fetch remote URLs with the preferred remote, then `origin`, first. */
1129
export function parseFetchRemoteUrls(remotesOutput: string | undefined, preferredRemote?: string): string[] | undefined {
1131
return undefined;
1132
}
1134
>
for (const rawLine of remotesOutput.split(/\r?\n/)) {
1135
>
const match = /^(\S+)\s+(\S+)\s+\(fetch\)$/.exec(rawLine.trim());
1136
>
if (match) {
1137
candidates.push({ name: match[1], url: match[2] });
1138
}
1140
>
const preferredNames = new Set([preferredRemote, 'origin'].filter((name): name is string => Boolean(name)));
1141
>
const ordered = [
1142
>
...candidates.filter(candidate => candidate.name === preferredRemote),
1143
>
...candidates.filter(candidate => candidate.name === 'origin' && candidate.name !== preferredRemote),
1144
>
...candidates.filter(candidate => !preferredNames.has(candidate.name)),
1145
>
];
1146
>
return [...new Set(ordered.map(candidate => candidate.url))];
1147
>
}
1148
1149
/**