Merge pull request #64619 from Microsoft/rmacfarlane/git-apply

Add GitErrorCode to apply command
This commit is contained in:
João Moreno 2018-12-10 10:32:59 +01:00 committed by GitHub
commit 0cdd4b1241
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -214,4 +214,5 @@ export const enum GitErrorCodes {
WrongCase = 'WrongCase',
CantLockRef = 'CantLockRef',
CantRebaseMultipleBranches = 'CantRebaseMultipleBranches',
PatchDoesNotApply = 'PatchDoesNotApply'
}

View file

@ -829,7 +829,15 @@ export class Repository {
args.push('-R');
}
await this.run(args);
try {
await this.run(args);
} catch (err) {
if (/patch does not apply/.test(err.stderr)) {
err.gitErrorCode = GitErrorCodes.PatchDoesNotApply;
}
throw err;
}
}
async diff(cached = false): Promise<string> {