diff --git a/src/vs/workbench/parts/git/browser/gitActions.ts b/src/vs/workbench/parts/git/browser/gitActions.ts index 729ca7ae81779f8f78795b85c10a504a49b4e762..57cb5219e20d5854bb560da3a271432e81f21225 100644 --- a/src/vs/workbench/parts/git/browser/gitActions.ts +++ b/src/vs/workbench/parts/git/browser/gitActions.ts @@ -819,9 +819,14 @@ export class SmartCommitAction extends BaseCommitAction { export class PullAction extends GitAction { static ID = 'workbench.action.pull'; + static LABEL = nls.localize('pull', "Pull"); - constructor(@IGitService gitService: IGitService) { - super(PullAction.ID, nls.localize('pull', "Pull"), 'git-action pull', gitService); + constructor( + id = PullAction.ID, + label = PullAction.LABEL, + @IGitService gitService: IGitService + ) { + super(id, label, 'git-action pull', gitService); } protected isEnabled():boolean { @@ -844,7 +849,11 @@ export class PullAction extends GitAction { } public run(context?: any):Promise { - return this.gitService.pull().then(null, (err) => { + return this.pull(); + } + + protected pull(rebase = false): Promise { + return this.gitService.pull(rebase).then(null, (err) => { if (err.gitErrorCode === GitErrorCodes.DirtyWorkTree) { return Promise.wrapError(errors.create(nls.localize('dirtyTreePull', "Can't pull. Please commit or stage your work first."), { severity: Severity.Warning })); } else if (err.gitErrorCode === GitErrorCodes.AuthenticationFailed) { @@ -856,6 +865,20 @@ export class PullAction extends GitAction { } } +export class PullWithRebaseAction extends PullAction { + + static ID = 'workbench.action.pull.rebase'; + static LABEL = nls.localize('pullWithRebase', "Pull (Rebase)"); + + constructor(@IGitService gitService: IGitService) { + super(PullWithRebaseAction.ID, PullWithRebaseAction.LABEL, gitService); + } + + public run(context?: any):Promise { + return this.pull(true); + } +} + export class PushAction extends GitAction { static ID = 'workbench.action.push'; diff --git a/src/vs/workbench/parts/git/browser/gitServices.ts b/src/vs/workbench/parts/git/browser/gitServices.ts index 5b11b5fd223acaa0e61e636cbdb86cb89ffcd23e..24a897d17f657414b949cd4d2b6c1bfc5969c44c 100644 --- a/src/vs/workbench/parts/git/browser/gitServices.ts +++ b/src/vs/workbench/parts/git/browser/gitServices.ts @@ -553,8 +553,8 @@ export class GitService extends ee.EventEmitter return this.run(git.ServiceOperations.BACKGROUND_FETCH, () => this.raw.fetch()); } - public pull(): winjs.Promise { - return this.run(git.ServiceOperations.PULL, () => this.raw.pull()); + public pull(rebase?: boolean): winjs.Promise { + return this.run(git.ServiceOperations.PULL, () => this.raw.pull(rebase)); } public push(): winjs.Promise { diff --git a/src/vs/workbench/parts/git/browser/views/changes/changesView.ts b/src/vs/workbench/parts/git/browser/views/changes/changesView.ts index 6bea2ae9707dc64dafe116b878748d3927bd0559..b91d27a6d55d97802365df637f5a0ec9eb988a4d 100644 --- a/src/vs/workbench/parts/git/browser/views/changes/changesView.ts +++ b/src/vs/workbench/parts/git/browser/views/changes/changesView.ts @@ -248,7 +248,8 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV if (!this.secondaryActions) { this.secondaryActions = [ this.instantiationService.createInstance(GitActions.SyncAction, GitActions.SyncAction.ID, GitActions.SyncAction.LABEL), - this.instantiationService.createInstance(GitActions.PullAction), + this.instantiationService.createInstance(GitActions.PullAction, GitActions.PullAction.ID, GitActions.PullAction.LABEL), + this.instantiationService.createInstance(GitActions.PullWithRebaseAction), this.instantiationService.createInstance(GitActions.PushAction), new ActionBar.Separator(), this.instantiationService.createInstance(GitActions.CommitAction, this), diff --git a/src/vs/workbench/parts/git/common/git.ts b/src/vs/workbench/parts/git/common/git.ts index 0e006bd1db42d0ffb5b81ea43dd46e4199f282fb..63165657ed1a1d352b6f3925fcd82c73b51df6ab 100644 --- a/src/vs/workbench/parts/git/common/git.ts +++ b/src/vs/workbench/parts/git/common/git.ts @@ -259,7 +259,7 @@ export interface IRawGitService { reset(treeish:string, hard?: boolean): WinJS.TPromise; revertFiles(treeish:string, filePaths?: string[]): WinJS.TPromise; fetch(): WinJS.TPromise; - pull(): WinJS.TPromise; + pull(rebase?: boolean): WinJS.TPromise; push(): WinJS.TPromise; sync(): WinJS.TPromise; commit(message:string, amend?: boolean, stage?: boolean): WinJS.TPromise; @@ -285,7 +285,7 @@ export interface IGitService extends EventEmitter.IEventEmitter { reset(treeish:string, hard?: boolean): WinJS.TPromise; revertFiles(treeish:string, files?: IFileStatus[]): WinJS.TPromise; fetch(): WinJS.TPromise; - pull(): WinJS.TPromise; + pull(rebase?: boolean): WinJS.TPromise; push(): WinJS.TPromise; sync(): WinJS.TPromise; commit(message:string, amend?: boolean, stage?: boolean): WinJS.TPromise; diff --git a/src/vs/workbench/parts/git/common/noopGitService.ts b/src/vs/workbench/parts/git/common/noopGitService.ts index 295df50a36a5bfe7fef7eb45d1000f769e9da993..1c755742c4a623cac29ce6ba746907fb52d6a94a 100644 --- a/src/vs/workbench/parts/git/common/noopGitService.ts +++ b/src/vs/workbench/parts/git/common/noopGitService.ts @@ -65,7 +65,7 @@ export class NoOpGitService implements git.IRawGitService { return winjs.Promise.as(NoOpGitService.STATUS); } - public pull(): winjs.TPromise { + public pull(rebase?: boolean): winjs.TPromise { return winjs.Promise.as(NoOpGitService.STATUS); } diff --git a/src/vs/workbench/parts/git/node/git.lib.ts b/src/vs/workbench/parts/git/node/git.lib.ts index bd8173162a8e23811aebabf374c033b1d5b109d7..935617acb3668ba1309b38ed426640f04d21a501 100644 --- a/src/vs/workbench/parts/git/node/git.lib.ts +++ b/src/vs/workbench/parts/git/node/git.lib.ts @@ -506,8 +506,11 @@ export class Repository { }); } - public pull(): Promise { - return this.run(['pull']).then(null, (err: GitError) => { + public pull(rebase?: boolean): Promise { + const args = ['pull']; + rebase && args.push('-r'); + + return this.run(args).then(null, (err: GitError) => { if (/^CONFLICT \([^)]+\): \b/m.test(err.stdout)) { err.gitErrorCode = GitErrorCodes.Conflict; } else if (/Please tell me who you are\./.test(err.stderr)) { diff --git a/src/vs/workbench/parts/git/node/rawGitService.ts b/src/vs/workbench/parts/git/node/rawGitService.ts index 0cb084750c5e8217e0a1b06ee8f085bf876d6278..79c8dc596e09c1bccf4a62503ebc979f6b834d2c 100644 --- a/src/vs/workbench/parts/git/node/rawGitService.ts +++ b/src/vs/workbench/parts/git/node/rawGitService.ts @@ -116,8 +116,8 @@ export class RawGitService implements IRawGitService { }).then(() => this.status()); } - public pull(): TPromise { - return this.repo.pull().then(() => this.status()); + public pull(rebase?: boolean): TPromise { + return this.repo.pull(rebase).then(() => this.status()); } public push(): TPromise { @@ -235,8 +235,8 @@ export class DelayedRawGitService implements IRawGitService { return this.raw.then(raw => raw.fetch()); } - public pull(): TPromise { - return this.raw.then(raw => raw.pull()); + public pull(rebase?: boolean): TPromise { + return this.raw.then(raw => raw.pull(rebase)); } public push(): TPromise {