MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / getRemoteInfo2

Function getRemoteInfo2

src/api/getRemoteInfo2.js:54–113  ·  view source on GitHub ↗
({
  http,
  onAuth,
  onAuthSuccess,
  onAuthFailure,
  corsProxy,
  url,
  headers = {},
  forPush = false,
  protocolVersion = 2,
})

Source from the content-addressed store, hash-verified

52 *
53 */
54export async function getRemoteInfo2({
55 http,
56 onAuth,
57 onAuthSuccess,
58 onAuthFailure,
59 corsProxy,
60 url,
61 headers = {},
62 forPush = false,
63 protocolVersion = 2,
64}) {
65 try {
66 assertParameter('http', http)
67 assertParameter('url', url)
68
69 const GitRemoteHTTP = GitRemoteManager.getRemoteHelperFor({ url })
70 const remote = await GitRemoteHTTP.discover({
71 http,
72 onAuth,
73 onAuthSuccess,
74 onAuthFailure,
75 corsProxy,
76 service: forPush ? 'git-receive-pack' : 'git-upload-pack',
77 url,
78 headers,
79 protocolVersion,
80 })
81
82 if (remote.protocolVersion === 2) {
83 /** @type GetRemoteInfo2Result */
84 return {
85 protocolVersion: remote.protocolVersion,
86 capabilities: remote.capabilities2,
87 }
88 }
89
90 // Note: remote.capabilities, remote.refs, and remote.symrefs are Set and Map objects,
91 // but one of the objectives of the public API is to always return JSON-compatible objects
92 // so we must JSONify them.
93 /** @type Object<string, true> */
94 const capabilities = {}
95 for (const cap of remote.capabilities) {
96 const [key, value] = cap.split('=')
97 if (value) {
98 capabilities[key] = value
99 } else {
100 capabilities[key] = true
101 }
102 }
103 /** @type GetRemoteInfo2Result */
104 return {
105 protocolVersion: 1,
106 capabilities,
107 refs: formatInfoRefs(remote, undefined, true, true),
108 }
109 } catch (err) {
110 err.caller = 'git.getRemoteInfo2'
111 throw err

Calls 4

assertParameterFunction · 0.90
formatInfoRefsFunction · 0.90
getRemoteHelperForMethod · 0.80
discoverMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…