diff --git a/extensions/git/package.json b/extensions/git/package.json index 9c4fda1baebab001f31779bb3a64465e23cf86ab..daf74ad475be8dbcf7baca88f182e0698f5d073a 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -119,6 +119,16 @@ "title": "Undo Last Commit", "category": "Git" }, + { + "command": "git.checkout", + "title": "Checkout to...", + "category": "Git" + }, + { + "command": "git.branch", + "title": "Create Branch...", + "category": "Git" + }, { "command": "git.pull", "title": "Pull", diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 71372a50a37889a62498280d417f8352a1ba5d11..fedc616db14a574ad0712046052533a1eee0db13 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -295,6 +295,36 @@ export class CommandCenter { return await this.model.clean(...this.model.workingTreeGroup.resources); } + @CommandCenter.Command('git.commitStaged') + @CommandCenter.CatchErrors + async commitStaged(): Promise { + await Promise.reject('not implemented'); + } + + @CommandCenter.Command('git.commitStagedSigned') + @CommandCenter.CatchErrors + async commitStagedSigned(): Promise { + await Promise.reject('not implemented'); + } + + @CommandCenter.Command('git.commitAll') + @CommandCenter.CatchErrors + async commitAll(): Promise { + await Promise.reject('not implemented'); + } + + @CommandCenter.Command('git.commitAllSigned') + @CommandCenter.CatchErrors + async commitAllSigned(): Promise { + await Promise.reject('not implemented'); + } + + @CommandCenter.Command('git.undoCommit') + @CommandCenter.CatchErrors + async undoCommit(): Promise { + await Promise.reject('not implemented'); + } + @CommandCenter.Command('git.checkout') @CommandCenter.CatchErrors async checkout(): Promise { @@ -323,34 +353,20 @@ export class CommandCenter { await choice.run(this.model); } - @CommandCenter.Command('git.commitStaged') - @CommandCenter.CatchErrors - async commitStaged(): Promise { - await Promise.reject('not implemented'); - } - - @CommandCenter.Command('git.commitStagedSigned') - @CommandCenter.CatchErrors - async commitStagedSigned(): Promise { - await Promise.reject('not implemented'); - } - - @CommandCenter.Command('git.commitAll') + @CommandCenter.Command('git.branch') @CommandCenter.CatchErrors - async commitAll(): Promise { - await Promise.reject('not implemented'); - } + async branch(): Promise { + const result = await window.showInputBox({ + placeHolder: 'Branch name', + prompt: 'Please provide a branch name' + }); - @CommandCenter.Command('git.commitAllSigned') - @CommandCenter.CatchErrors - async commitAllSigned(): Promise { - await Promise.reject('not implemented'); - } + if (!result) { + return; + } - @CommandCenter.Command('git.undoCommit') - @CommandCenter.CatchErrors - async undoCommit(): Promise { - await Promise.reject('not implemented'); + const name = result.replace(/^\.|\/\.|\.\.|~|\^|:|\/$|\.lock$|\.lock\/|\\|\*|\s|^\s*$|\.$/g, '-'); + await this.model.branch(name); } @CommandCenter.Command('git.pull') diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index c874b8c21806d2460c32b94fad296a66ee13904f..91df39977b0d5985be8d7617a04c12e4cb64b190 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -322,6 +322,11 @@ export class Model { await this.update(); } + async branch(name: string): Promise { + await this.repository.branch(name, true); + await this.update(); + } + async checkout(treeish: string): Promise { await this.repository.checkout(treeish, []); await this.update();