<commit_before>import { git, envForAuthentication, expectedAuthenticationErrors, GitError } from './core'
import { Repository } from '../../models/repository'
import { Account } from '../../models/account'

/** Pull from the remote to the branch. */
export async function pull(repository: Repository, account: Account | null, remote: string, branch: string): Promise<void> {

  const options = {
    env: envForAuthentication(account),
    expectedErrors: expectedAuthenticationErrors(),
  }

  const args = [ 'pull', remote, branch ]
  const result = await git(args, repository.path, 'pull', options)

  if (result.gitErrorDescription) {
    return Promise.reject(new GitError(result, args))
  }

  return Promise.resolve()
}<commit_msg>Expose progress for pull<commit_after>import { git, envForAuthentication, expectedAuthenticationErrors, GitError, IGitExecutionOptions } from './core'
import { Repository } from '../../models/repository'
import { Account } from '../../models/account'
import { ChildProcess } from 'child_process'

const byline = require('byline')

/** Pull from the remote to the branch. */
export async function pull(repository: Repository, account: Account | null, remote: string, branch: string, progressCallback?: (line: string) => void): Promise<void> {

  let options: IGitExecutionOptions = {
    env: envForAuthentication(account),
    expectedErrors: expectedAuthenticationErrors(),
  }

  if (progressCallback) {
    options = {
      ...options,
      processCallback: (process: ChildProcess) => {
        byline(process.stderr).on('data', (chunk: string) => {
          progressCallback(chunk)
        })
      },
    }
  }

  const args = progressCallback
    ? [ 'pull', '--progress', remote, branch ]
    : [ 'pull', remote, branch ]

  const result = await git(args, repository.path, 'pull', options)

  if (result.gitErrorDescription) {
    return Promise.reject(new GitError(result, args))
  }

  return Promise.resolve()
}
{'fraction_non_alphanumeric': 0.13353720693170235, 'fraction_numerical': 0.0, 'mean_word_length': 3.982233502538071, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1514600', 'n_tokens_mistral': 531, 'n_tokens_neox': 521, 'n_words': 154}