diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index b607a5fb2cb..8feb78d81c5 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -277,7 +277,9 @@ export const GitErrorCodes = { RepositoryNotFound: 'RepositoryNotFound', RepositoryIsLocked: 'RepositoryIsLocked', BranchNotFullyMerged: 'BranchNotFullyMerged', - NoRemoteReference: 'NoRemoteReference' + NoRemoteReference: 'NoRemoteReference', + InvalidBranchName: 'InvalidBranchName', + BranchAlreadyExists: 'BranchAlreadyExists' }; function getGitErrorCode(stderr: string): string | undefined { @@ -299,6 +301,10 @@ function getGitErrorCode(stderr: string): string | undefined { return GitErrorCodes.BranchNotFullyMerged; } else if (/Couldn\'t find remote ref/.test(stderr)) { return GitErrorCodes.NoRemoteReference; + } else if (/A branch named '.+' already exists/.test(stderr)) { + return GitErrorCodes.BranchAlreadyExists; + } else if (/'.+' is not a valid branch name/.test(stderr)) { + return GitErrorCodes.InvalidBranchName; } return void 0; @@ -667,6 +673,11 @@ export class Repository { await this.run(args); } + async renameBranch(name: string): Promise { + const args = ['branch', '-m', name]; + await this.run(args); + } + async merge(ref: string): Promise { const args = ['merge', ref];