MCPcopy Create free account
hub / github.com/desktop/desktop / fetchRepositoryCloneInfo

Method fetchRepositoryCloneInfo

app/src/lib/api.ts:1010–1030  ·  view source on GitHub ↗

* Fetch info needed to clone a repository. That includes: * - The canonical clone URL for a repository, respecting the protocol * preference if provided. * - The default branch of the repository, in case the repository is empty. * Only available for GitHub repositories. * *

(
    owner: string,
    name: string,
    protocol: GitProtocol | undefined
  )

Source from the content-addressed store, hash-verified

1008 * @param protocol The preferred Git protocol (https or ssh)
1009 */
1010 public async fetchRepositoryCloneInfo(
1011 owner: string,
1012 name: string,
1013 protocol: GitProtocol | undefined
1014 ): Promise<IAPIRepositoryCloneInfo | null> {
1015 const response = await this.ghRequest('GET', `repos/${owner}/${name}`, {
1016 // Make sure we don't run into cache issues when fetching the repositories,
1017 // specially after repositories have been renamed.
1018 reloadCache: true,
1019 })
1020
1021 if (response.status === HttpStatusCode.NotFound) {
1022 return null
1023 }
1024
1025 const repo = await parsedResponse<IAPIRepository>(response)
1026 return {
1027 url: protocol === 'ssh' ? repo.ssh_url : repo.clone_url,
1028 defaultBranch: repo.default_branch,
1029 }
1030 }
1031
1032 /**
1033 * Fetch all repos a user has access to in a streaming fashion. The callback

Callers 1

resolveCloneInfoMethod · 0.80

Calls 1

ghRequestMethod · 0.95

Tested by

no test coverage detected