( repository: Repository, remote: IRemote, localBranch: string, remoteBranch: string | null, tagsToPush: ReadonlyArray<string> | null, options?: PushOptions, progressCallback?: (progress: IPushProgress) => void )
| 46 | * 'git push'. |
| 47 | */ |
| 48 | export async function push( |
| 49 | repository: Repository, |
| 50 | remote: IRemote, |
| 51 | localBranch: string, |
| 52 | remoteBranch: string | null, |
| 53 | tagsToPush: ReadonlyArray<string> | null, |
| 54 | options?: PushOptions, |
| 55 | progressCallback?: (progress: IPushProgress) => void |
| 56 | ): Promise<void> { |
| 57 | const args = [ |
| 58 | 'push', |
| 59 | remote.name, |
| 60 | remoteBranch ? `${localBranch}:${remoteBranch}` : localBranch, |
| 61 | ] |
| 62 | |
| 63 | if (tagsToPush !== null) { |
| 64 | args.push(...tagsToPush) |
| 65 | } |
| 66 | if (!remoteBranch) { |
| 67 | args.push('--set-upstream') |
| 68 | } else if (options?.forceWithLease) { |
| 69 | args.push('--force-with-lease') |
| 70 | } |
| 71 | |
| 72 | if (options?.noVerify) { |
| 73 | args.push('--no-verify') |
| 74 | } |
| 75 | |
| 76 | let opts: IGitStringExecutionOptions = { |
| 77 | env: await envForRemoteOperation(remote.url), |
| 78 | interceptHooks: ['pre-push'], |
| 79 | onHookProgress: options?.onHookProgress, |
| 80 | onHookFailure: options?.onHookFailure, |
| 81 | onTerminalOutputAvailable: options?.onTerminalOutputAvailable, |
| 82 | } |
| 83 | |
| 84 | if (progressCallback) { |
| 85 | args.push('--progress') |
| 86 | const title = `Pushing to ${remote.name}` |
| 87 | const kind = 'push' |
| 88 | |
| 89 | opts = await executionOptionsWithProgress( |
| 90 | { ...opts, trackLFSProgress: true }, |
| 91 | new PushProgressParser(), |
| 92 | progress => { |
| 93 | const description = |
| 94 | progress.kind === 'progress' ? progress.details.text : progress.text |
| 95 | const value = progress.percent |
| 96 | |
| 97 | progressCallback({ |
| 98 | kind, |
| 99 | title, |
| 100 | description, |
| 101 | value, |
| 102 | remote: remote.name, |
| 103 | branch: localBranch, |
| 104 | }) |
| 105 | } |
no test coverage detected