MCPcopy Index your code
hub / github.com/desktop/desktop / getFallbackUrlForProxyResolve

Function getFallbackUrlForProxyResolve

app/src/lib/git/environment.ts:29–57  ·  view source on GitHub ↗
(
  repository: Repository,
  currentRemote: IRemote | null
)

Source from the content-addressed store, hash-verified

27 * that as the probable url to resolve a proxy for.
28 */
29export function getFallbackUrlForProxyResolve(
30 repository: Repository,
31 currentRemote: IRemote | null
32) {
33 // We used to use account.endpoint here but we look up account by the
34 // repository endpoint (see getAccountForRepository) so we can skip the use
35 // of the account here and just use the repository endpoint directly.
36 if (isRepositoryWithGitHubRepository(repository)) {
37 return getHTMLURL(repository.gitHubRepository.endpoint)
38 }
39
40 // This is a carry-over from the old code where we would use the current
41 // remote to resolve an account and then use that account's endpoint here.
42 // We've since removed the need to pass an account down here but unfortunately
43 // that means we need to pass the current remote instead. Note that ideally
44 // this should be looking up the remote url either based on the currently
45 // checked out branch, the upstream tracking branch of the branch being
46 // checked out, or the default remote if neither of those are available.
47 // Doing so by shelling out to Git here was deemed to costly and in order to
48 // finish this refactor we've opted to replicate the previous behavior here.
49 if (currentRemote) {
50 return currentRemote.url
51 }
52
53 // If all else fails let's assume that whatever network resource
54 // Git is gonna hit it's gonna be using the same proxy as it would
55 // if it was a GitHub.com endpoint
56 return 'https://github.com'
57}
58
59/**
60 * Create a set of environment variables to use when invoking a Git

Callers 3

revertCommitFunction · 0.90
getCheckoutOptsFunction · 0.90

Calls 2

getHTMLURLFunction · 0.90

Tested by

no test coverage detected