MCPcopy
hub / github.com/desktop/desktop / fetch

Function fetch

app/src/lib/git/fetch.ts:39–89  ·  view source on GitHub ↗
(
  repository: Repository,
  remote: IRemote,
  progressCallback?: (progress: IFetchProgress) => void,
  isBackgroundTask = false
)

Source from the content-addressed store, hash-verified

37 * background task as opposed to being user initiated
38 */
39export async function fetch(
40 repository: Repository,
41 remote: IRemote,
42 progressCallback?: (progress: IFetchProgress) => void,
43 isBackgroundTask = false
44): Promise<void> {
45 let opts: IGitStringExecutionOptions = {
46 successExitCodes: new Set([0]),
47 env: await envForRemoteOperation(remote.url),
48 }
49
50 if (progressCallback) {
51 const title = `Fetching ${remote.name}`
52 const kind = 'fetch'
53
54 opts = await executionOptionsWithProgress(
55 { ...opts, trackLFSProgress: true, isBackgroundTask },
56 new FetchProgressParser(),
57 progress => {
58 // In addition to progress output from the remote end and from
59 // git itself, the stderr output from pull contains information
60 // about ref updates. We don't need to bring those into the progress
61 // stream so we'll just punt on anything we don't know about for now.
62 if (progress.kind === 'context') {
63 if (!progress.text.startsWith('remote: Counting objects')) {
64 return
65 }
66 }
67
68 const description =
69 progress.kind === 'progress' ? progress.details.text : progress.text
70 const value = progress.percent
71
72 progressCallback({
73 kind,
74 title,
75 description,
76 value,
77 remote: remote.name,
78 })
79 }
80 )
81
82 // Initial progress
83 progressCallback({ kind, title, value: 0, remote: remote.name })
84 }
85
86 const args = await getFetchArgs(remote.name, progressCallback)
87
88 await git(args, repository.path, 'fetch', opts)
89}
90
91/** Fetch a given refspec from the given remote. */
92export async function fetchRefspec(

Callers 8

setupFunction · 0.90
setupFunction · 0.90
setupFunction · 0.90
requestFunction · 0.85
getChangeLogFunction · 0.85
isGitHubHostFunction · 0.85

Calls 4

envForRemoteOperationFunction · 0.90
gitFunction · 0.90
getFetchArgsFunction · 0.85

Tested by

no test coverage detected