diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index eed354dd8a4f1ce18aede020ea2e9c112e1e4024..127544276ab137be271a3a99a03a81044a634ba6 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -774,7 +774,7 @@ export class CommandCenter { return; } - await this.model.pull(true); + await this.model.pullWithRebase(); } @command('git.push') @@ -812,7 +812,7 @@ export class CommandCenter { return; } - this.model.push(pick.label, branchName); + this.model.pushTo(pick.label, branchName); } @command('git.sync') @@ -860,7 +860,7 @@ export class CommandCenter { return; } - await this.model.push(choice, branchName, { setUpstream: true }); + await this.model.pushTo(choice, branchName, true); } @command('git.showOutput') diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 9ef482def9318be80e4e4401b43412f47cc6710a..ad023efdf6ea76006f28df514c4061b3c2184b90 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -21,10 +21,6 @@ export interface IGit { version: string; } -export interface PushOptions { - setUpstream?: boolean; -} - export interface IFileStatus { x: string; y: string; @@ -762,10 +758,10 @@ export class Repository { } } - async push(remote?: string, name?: string, options?: PushOptions): Promise { + async push(remote?: string, name?: string, setUpstream: boolean = false): Promise { const args = ['push']; - if (options && options.setUpstream) { + if (setUpstream) { args.push('-u'); } diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index aba4a4251d621804186de53fedc92145cc561d0e..56479c7121c930a6daced8ce5a60583d2f71f092 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -6,7 +6,7 @@ 'use strict'; import { Uri, Command, EventEmitter, Event, SourceControlResourceState, SourceControlResourceDecorations, Disposable, ProgressLocation, window, workspace } from 'vscode'; -import { Git, Repository, Ref, Branch, Remote, PushOptions, Commit, GitErrorCodes } from './git'; +import { Git, Repository, Ref, Branch, Remote, Commit, GitErrorCodes } from './git'; import { anyEvent, eventToPromise, filterEvent, EmptyDisposable, combinedDisposable, dispose } from './util'; import { memoize, throttle, debounce } from './decorators'; import * as path from 'path'; @@ -479,12 +479,23 @@ export class Model implements Disposable { } } - async pull(rebase?: boolean): Promise { - await this.run(Operation.Pull, () => this.repository.pull(rebase)); + @throttle + async pull(): Promise { + await this.run(Operation.Pull, () => this.repository.pull()); + } + + @throttle + async pullWithRebase(): Promise { + await this.run(Operation.Pull, () => this.repository.pull(true)); + } + + @throttle + async push(): Promise { + await this.run(Operation.Push, () => this.repository.push()); } - async push(remote?: string, name?: string, options?: PushOptions): Promise { - await this.run(Operation.Push, () => this.repository.push(remote, name, options)); + async pushTo(remote?: string, name?: string, setUpstream: boolean = false): Promise { + await this.run(Operation.Push, () => this.repository.push(remote, name, setUpstream)); } @throttle