Changing autofetch to a string config which has "current", "all" and (#111090)

This commit is contained in:
Jason Williams
2020-12-11 05:54:21 +00:00
committed by GitHub
parent 39f78228fa
commit 83f43bee1d
3 changed files with 32 additions and 7 deletions

View File

@@ -23,6 +23,7 @@ export class AutoFetcher {
private onDidChange = this._onDidChange.event;
private _enabled: boolean = false;
private _fetchAll: boolean = false;
get enabled(): boolean { return this._enabled; }
set enabled(enabled: boolean) { this._enabled = enabled; this._onDidChange.fire(enabled); }
@@ -70,10 +71,20 @@ export class AutoFetcher {
private onConfiguration(): void {
const gitConfig = workspace.getConfiguration('git', Uri.file(this.repository.root));
if (gitConfig.get<boolean>('autofetch') === false) {
this.disable();
} else {
this.enable();
switch (gitConfig.get<boolean | 'all'>('autofetch')) {
case true:
this._fetchAll = false;
this.enable();
break;
case 'all':
this._fetchAll = true;
this.enable();
break;
case false:
default:
this._fetchAll = false;
this.disable();
break;
}
}
@@ -99,7 +110,11 @@ export class AutoFetcher {
}
try {
await this.repository.fetchDefault({ silent: true });
if (this._fetchAll) {
await this.repository.fetchAll();
} else {
await this.repository.fetchDefault({ silent: true });
}
} catch (err) {
if (err.gitErrorCode === GitErrorCodes.AuthenticationFailed) {
this.disable();