diff --git a/extensions/git/package.json b/extensions/git/package.json index 6db5f813cc3..eb37fcac1cf 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -98,6 +98,11 @@ "command": "git.publish", "title": "Publish", "category": "Git" + }, + { + "command": "git.sync", + "title": "Sync", + "category": "Git" } ], "menus": { diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 8315b81a694..76cc3725c59 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -91,6 +91,7 @@ class CommandCenter { commands.registerCommand('git.clean', this.clean, this), commands.registerCommand('git.cleanAll', this.cleanAll, this), commands.registerCommand('git.checkout', this.checkout, this), + commands.registerCommand('git.sync', this.sync, this), commands.registerCommand('git.publish', this.publish, this), ); } @@ -204,6 +205,11 @@ class CommandCenter { await choice.run(this.model); } + @decorate(catchErrors) + async sync(): Promise { + await this.model.sync(); + } + @decorate(catchErrors) async publish(): Promise { const branchName = this.model.HEAD && this.model.HEAD.name || ''; diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index 8fac407207e..c874b8c2180 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -327,6 +327,11 @@ export class Model { await this.update(); } + async sync(): Promise { + await this.repository.sync(); + await this.update(); + } + async push(remote?: string, name?: string, options?: IPushOptions): Promise { await this.repository.push(remote, name, options); await this.update();