MCPcopy
hub / github.com/desktop/desktop / push

Function push

app/src/lib/git/push.ts:48–119  ·  view source on GitHub ↗
(
  repository: Repository,
  remote: IRemote,
  localBranch: string,
  remoteBranch: string | null,
  tagsToPush: ReadonlyArray<string> | null,
  options?: PushOptions,
  progressCallback?: (progress: IPushProgress) => void
)

Source from the content-addressed store, hash-verified

46 * 'git push'.
47 */
48export 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 }

Callers 2

push-test.tsFile · 0.90
tag-test.tsFile · 0.90

Calls 4

envForRemoteOperationFunction · 0.90
gitFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected