MCPcopy Create free account
hub / github.com/Kong/insomnia / fetchRemoteBranches

Function fetchRemoteBranches

packages/insomnia/src/sync/git/git-vcs.ts:2178–2207  ·  view source on GitHub ↗
({ uri, credentialsId }: { uri: string; credentialsId?: string | null })

Source from the content-addressed store, hash-verified

2176}
2177
2178export async function fetchRemoteBranches({ uri, credentialsId }: { uri: string; credentialsId?: string | null }) {
2179 const [mainRef] = await git.listServerRefs({
2180 ...gitCallbacks(credentialsId),
2181 http: httpClient,
2182 url: uri,
2183 prefix: 'HEAD',
2184 symrefs: true,
2185 });
2186
2187 const remoteRefs = await git.listServerRefs({
2188 ...gitCallbacks(credentialsId),
2189 http: httpClient,
2190 url: uri,
2191 prefix: 'refs/heads/',
2192 symrefs: true,
2193 });
2194
2195 const defaultBranch = mainRef?.target?.replace('refs/heads/', '') || 'main';
2196
2197 const remoteBranches = remoteRefs
2198 .filter(b => b.ref !== 'HEAD')
2199 .map(b => b.ref.replace('refs/heads/', ''))
2200 .sort((a, b) => {
2201 if (a === defaultBranch) return -1;
2202 if (b === defaultBranch) return 1;
2203 return a.localeCompare(b);
2204 });
2205
2206 return remoteBranches;
2207}
2208
2209export default new GitVCS();

Callers 2

validateGitCredentialsFunction · 0.90
fetchGitRemoteBranchesFunction · 0.90

Calls 3

gitCallbacksFunction · 0.90
mapMethod · 0.80
filterMethod · 0.80

Tested by

no test coverage detected