git.pruneOnFetch setting implemented

This commit is contained in:
Oliver Larsson
2020-01-24 21:20:44 +01:00
parent a93ffac38a
commit 2abdb90472
3 changed files with 24 additions and 4 deletions
+6
View File
@@ -1548,6 +1548,12 @@
"default": false,
"description": "%config.fetchOnPull%"
},
"git.pruneOnFetch": {
"type": "boolean",
"scope": "resource",
"default": false,
"description": "%config.pruneOnFetch%"
},
"git.pullTags": {
"type": "boolean",
"scope": "resource",
+1
View File
@@ -128,6 +128,7 @@
"config.confirmEmptyCommits": "Always confirm the creation of empty commits for the 'Git: Commit Empty' command.",
"config.fetchOnPull": "Fetch all branches when pulling or just the current one.",
"config.pullTags": "Fetch all tags when pulling.",
"config.pruneOnFetch": "Always prune when fetching.",
"config.autoStash": "Stash any changes before pulling and restore them after successful pull.",
"config.allowForcePush": "Controls whether force push (with or without lease) is enabled.",
"config.useForcePushWithLease": "Controls whether force pushing uses the safer force-with-lease variant.",
+17 -4
View File
@@ -1072,21 +1072,34 @@ export class Repository implements Disposable {
@throttle
async fetchDefault(options: { silent?: boolean } = {}): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch(options));
await this.fetchFrom({ silent: options.silent });
}
@throttle
async fetchPrune(): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch({ prune: true }));
await this.fetchFrom({ prune: true });
}
@throttle
async fetchAll(): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch({ all: true }));
await this.fetchFrom({ all: true });
}
async fetch(remote?: string, ref?: string, depth?: number): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch({ remote, ref, depth }));
await this.fetchFrom({ remote, ref, depth });
}
private async fetchFrom(options: { remote?: string, ref?: string, all?: boolean, prune?: boolean, depth?: number, silent?: boolean } = {}): Promise<void> {
await this.run(Operation.Fetch, async () => {
const config = workspace.getConfiguration('git', Uri.file(this.root));
const prune = config.get<boolean>('pruneOnFetch');
if (prune) {
options.prune = prune;
}
this.repository.fetch(options);
});
}
@throttle