Add error codes and func for rename branch

This commit is contained in:
Justin Horner
2017-08-10 14:03:16 -04:00
parent 24c05ae2f9
commit d76ae31041

View File

@@ -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<void> {
const args = ['branch', '-m', name];
await this.run(args);
}
async merge(ref: string): Promise<void> {
const args = ['merge', ref];