( repository: Repository, remote: IRemote, progressCallback?: (progress: IFetchProgress) => void, isBackgroundTask = false )
| 37 | * background task as opposed to being user initiated |
| 38 | */ |
| 39 | export 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. */ |
| 92 | export async function fetchRefspec( |
no test coverage detected