mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-17 12:10:22 -05:00
Merge commit 'refs/pull/59988/head' of github.com:Microsoft/vscode into pr/59988
This commit is contained in:
@@ -1024,6 +1024,12 @@
|
||||
"usesOnlineServices"
|
||||
]
|
||||
},
|
||||
"git.autofetchPeriod": {
|
||||
"type": "number",
|
||||
"scope": "resource",
|
||||
"description": "%config.autofetchPeriod%",
|
||||
"default": 3
|
||||
},
|
||||
"git.branchValidationRegex": {
|
||||
"type": "string",
|
||||
"description": "%config.branchValidationRegex%",
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
"config.autoRepositoryDetection.openEditors": "Scan for parent folders of open files.",
|
||||
"config.autorefresh": "Whether auto refreshing is enabled.",
|
||||
"config.autofetch": "When enabled, commits will automatically be fetched from the default remote of the current Git repository.",
|
||||
"config.autofetchPeriod": "Duration in minutes between each automatic git fetch, when `git.autofetch` is enabled.",
|
||||
"config.confirmSync": "Confirm before synchronizing git repositories.",
|
||||
"config.countBadge": "Controls the git badge counter.",
|
||||
"config.countBadge.all": "Count all changes.",
|
||||
@@ -119,4 +120,4 @@
|
||||
"colors.ignored": "Color for ignored resources.",
|
||||
"colors.conflict": "Color for resources with conflicts.",
|
||||
"colors.submodule": "Color for submodule resources."
|
||||
}
|
||||
}
|
||||
@@ -17,16 +17,19 @@ function isRemoteOperation(operation: Operation): boolean {
|
||||
|
||||
export class AutoFetcher {
|
||||
|
||||
private static readonly Period = 3 * 60 * 1000 /* three minutes */;
|
||||
private static DidInformUser = 'autofetch.didInformUser';
|
||||
|
||||
private _onDidChange = new EventEmitter<boolean>();
|
||||
private _onDidChange = new EventEmitter<boolean | number>();
|
||||
private onDidChange = this._onDidChange.event;
|
||||
|
||||
private _enabled: boolean = false;
|
||||
get enabled(): boolean { return this._enabled; }
|
||||
set enabled(enabled: boolean) { this._enabled = enabled; this._onDidChange.fire(enabled); }
|
||||
|
||||
private _timeout: number = workspace.getConfiguration('git').get<number>('autofetchPeriod', 3) * 60 * 1000;
|
||||
private get timeout(): number { return this._timeout; }
|
||||
private set timeout(minutes: number) { this._timeout = minutes * 60 * 1000; this._onDidChange.fire(minutes); }
|
||||
|
||||
private disposables: Disposable[] = [];
|
||||
|
||||
constructor(private repository: Repository, private globalState: Memento) {
|
||||
@@ -70,19 +73,19 @@ export class AutoFetcher {
|
||||
|
||||
private onConfiguration(): void {
|
||||
const gitConfig = workspace.getConfiguration('git');
|
||||
const minutes = gitConfig.get<number>('autofetchPeriod', 3);
|
||||
const autofetch = gitConfig.get<boolean>('autofetch');
|
||||
|
||||
if (gitConfig.get<boolean>('autofetch') === false) {
|
||||
this.disable();
|
||||
} else {
|
||||
this.enable();
|
||||
if (this.timeout !== minutes) {
|
||||
this.timeout = minutes;
|
||||
}
|
||||
|
||||
if (this.enabled !== autofetch) {
|
||||
autofetch ? this.enable() : this.disable();
|
||||
}
|
||||
}
|
||||
|
||||
enable(): void {
|
||||
if (this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.enabled = true;
|
||||
this.run();
|
||||
}
|
||||
@@ -111,9 +114,9 @@ export class AutoFetcher {
|
||||
return;
|
||||
}
|
||||
|
||||
const timeout = new Promise(c => setTimeout(c, AutoFetcher.Period));
|
||||
const whenDisabled = eventToPromise(filterEvent(this.onDidChange, enabled => !enabled));
|
||||
await Promise.race([timeout, whenDisabled]);
|
||||
const timeout = new Promise(c => setTimeout(c, this.timeout));
|
||||
const onChanged = eventToPromise(filterEvent(this.onDidChange, () => true));
|
||||
await Promise.race([timeout, onChanged]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user