This commit is contained in:
joaorreis 2018-12-17 14:47:35 +00:00
parent 8c09d4f476
commit 6dbf6b5857
2 changed files with 15 additions and 4 deletions

View file

@ -1197,7 +1197,7 @@ export class Repository {
}
}
async pull(rebase?: boolean, remote?: string, branch?: string): Promise<void> {
async pull(rebase?: boolean, remote?: string, branch?: string, cancellationToken?: CancellationToken): Promise<void> {
const args = ['pull', '--tags'];
if (rebase) {
@ -1210,7 +1210,7 @@ export class Repository {
}
try {
await this.run(args);
await this.run(args, { cancellationToken });
} catch (err) {
if (/^CONFLICT \([^)]+\): \b/m.test(err.stdout || '')) {
err.gitErrorCode = GitErrorCodes.Conflict;

View file

@ -1004,11 +1004,22 @@ export class Repository implements Disposable {
await this.run(Operation.Sync, async () => {
const config = workspace.getConfiguration('git', Uri.file(this.root));
const fetchOnPull = config.get<boolean>('fetchOnPull');
const opts = {
location: ProgressLocation.Notification,
title: localize('sync is unpredictable', "Syncing. Cancelling may cause serious damages to the repository"),
cancellable: true
};
if (fetchOnPull) {
await this.repository.pull(rebase);
await window.withProgress(
opts,
(_, token) => this.repository.pull(rebase, undefined, undefined, token)
);
} else {
await this.repository.pull(rebase, remoteName, pullBranch);
await window.withProgress(
opts,
(_, token) => this.repository.pull(rebase, remoteName, pullBranch, token)
);
}
const remote = this.remotes.find(r => r.name === remoteName);