From bcf2f1dabbb4df0804bbd5d2f811afdb19208cca Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 23 Aug 2017 16:12:46 +0200 Subject: [PATCH] git: init --- extensions/git/src/commands.ts | 19 +++++++++++++++++-- extensions/git/src/model.ts | 2 +- extensions/git/src/repository.ts | 17 ++++++++--------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index aee82cbe4fe..aa9f74a5ada 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -311,8 +311,23 @@ export class CommandCenter { @command('git.init') async init(): Promise { - // TODO@joao - // await model.init(); + const value = workspace.workspaceFolders && workspace.workspaceFolders.length > 0 + ? workspace.workspaceFolders[0].uri.fsPath + : os.homedir(); + + const path = await window.showInputBox({ + placeHolder: localize('path to init', "Folder path"), + prompt: localize('provide path', "Please provide a folder path to initialize a Git repository"), + value, + ignoreFocusOut: true + }); + + if (!path) { + return; + } + + await this.git.init(path); + await this.model.tryOpenRepository(path); } @command('git.openFile') diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index ed44caf52d5..278a095b38d 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -84,7 +84,7 @@ export class Model { } @sequentialize - private async tryOpenRepository(path: string): Promise { + async tryOpenRepository(path: string): Promise { const repository = this.getRepository(path); if (repository) { diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index d72b4783f23..ed2af08ee4f 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -201,15 +201,14 @@ export enum Operation { Pull = 1 << 9, Push = 1 << 10, Sync = 1 << 11, - Init = 1 << 12, - Show = 1 << 13, - Stage = 1 << 14, - GetCommitTemplate = 1 << 15, - DeleteBranch = 1 << 16, - Merge = 1 << 17, - Ignore = 1 << 18, - Tag = 1 << 19, - Stash = 1 << 20 + Show = 1 << 12, + Stage = 1 << 13, + GetCommitTemplate = 1 << 14, + DeleteBranch = 1 << 15, + Merge = 1 << 16, + Ignore = 1 << 17, + Tag = 1 << 18, + Stash = 1 << 19 } // function getOperationName(operation: Operation): string {