|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | | -import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env } from 'vscode'; |
| 6 | +import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env, ProgressOptions, CancellationToken } from 'vscode'; |
7 | 7 | import { Repository as BaseRepository, Commit, Stash, GitError, Submodule, CommitOptions, ForcePushMode } from './git'; |
8 | 8 | import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent, combinedDisposable, watch, IFileWatcher } from './util'; |
9 | 9 | import { memoize, throttle, debounce } from './decorators'; |
@@ -1146,11 +1146,22 @@ export class Repository implements Disposable { |
1146 | 1146 | const config = workspace.getConfiguration('git', Uri.file(this.root)); |
1147 | 1147 | const fetchOnPull = config.get<boolean>('fetchOnPull'); |
1148 | 1148 | const tags = config.get<boolean>('pullTags'); |
| 1149 | + const supportCancellation = config.get<boolean>('supportCancellation'); |
1149 | 1150 |
|
1150 | | - if (fetchOnPull) { |
1151 | | - await this.repository.pull(rebase, undefined, undefined, { tags }); |
| 1151 | + const fn = fetchOnPull |
| 1152 | + ? async (cancellationToken?: CancellationToken) => await this.repository.pull(rebase, undefined, undefined, { tags, cancellationToken }) |
| 1153 | + : async (cancellationToken?: CancellationToken) => await this.repository.pull(rebase, remoteName, pullBranch, { tags, cancellationToken }); |
| 1154 | + |
| 1155 | + if (supportCancellation) { |
| 1156 | + const opts: ProgressOptions = { |
| 1157 | + location: ProgressLocation.Notification, |
| 1158 | + title: localize('sync is unpredictable', "Syncing. Cancelling may cause serious damages to the repository"), |
| 1159 | + cancellable: true |
| 1160 | + }; |
| 1161 | + |
| 1162 | + await window.withProgress(opts, (_, token) => fn(token)); |
1152 | 1163 | } else { |
1153 | | - await this.repository.pull(rebase, remoteName, pullBranch, { tags }); |
| 1164 | + await fn(); |
1154 | 1165 | } |
1155 | 1166 |
|
1156 | 1167 | const remote = this.remotes.find(r => r.name === remoteName); |
|
0 commit comments