Git: Pull from specific branch

This commit is contained in:
Bugra Cuhadaroglu
2017-05-20 01:48:59 -04:00
parent a49a42680a
commit 39f33ae2ae
5 changed files with 63 additions and 6 deletions

View File

@@ -270,7 +270,8 @@ export const GitErrorCodes = {
CantAccessRemote: 'CantAccessRemote',
RepositoryNotFound: 'RepositoryNotFound',
RepositoryIsLocked: 'RepositoryIsLocked',
BranchNotFullyMerged: 'BranchNotFullyMerged'
BranchNotFullyMerged: 'BranchNotFullyMerged',
NoRemoteReference: 'NoRemoteReference'
};
function getGitErrorCode(stderr: string): string | undefined {
@@ -290,6 +291,8 @@ function getGitErrorCode(stderr: string): string | undefined {
return GitErrorCodes.CantAccessRemote;
} else if (/branch '.+' is not fully merged/.test(stderr)) {
return GitErrorCodes.BranchNotFullyMerged;
} else if (/Couldn\'t find remote ref/.test(stderr)) {
return GitErrorCodes.NoRemoteReference;
}
return void 0;
@@ -734,13 +737,21 @@ export class Repository {
}
}
async pull(rebase?: boolean): Promise<void> {
async pull(rebase?: boolean, remote?: string, name?: string): Promise<void> {
const args = ['pull'];
if (rebase) {
args.push('-r');
}
if (remote) {
args.push(remote);
}
if (name) {
args.push(name);
}
try {
await this.run(args);
} catch (err) {