提交 6cc0f065 编写于 作者: R Ryan Scott

Add git.fetchPrune

上级 52caa1a4
......@@ -265,6 +265,11 @@
"title": "%command.fetch%",
"category": "Git"
},
{
"command": "git.fetchPrune",
"title": "%command.fetchPrune%",
"category": "Git"
},
{
"command": "git.fetchAll",
"title": "%command.fetchAll%",
......
......@@ -37,6 +37,7 @@
"command.merge": "Merge Branch...",
"command.createTag": "Create Tag",
"command.fetch": "Fetch",
"command.fetchPrune": "Fetch (prune)",
"command.fetchAll": "Fetch From All Remotes",
"command.pull": "Pull",
"command.pullRebase": "Pull (Rebase)",
......
......@@ -1539,6 +1539,17 @@ export class CommandCenter {
await repository.fetchDefault();
}
@command('git.fetchPrune', { repository: true })
async fetchPrune(repository: Repository): Promise<void> {
if (repository.remotes.length === 0) {
window.showWarningMessage(localize('no remotes to fetch', "This repository has no remotes configured to fetch from."));
return;
}
await repository.fetchPrune();
}
@command('git.fetchAll', { repository: true })
async fetchAll(repository: Repository): Promise<void> {
if (repository.remotes.length === 0) {
......
......@@ -1159,7 +1159,7 @@ export class Repository {
await this.run(args);
}
async fetch(options: { remote?: string, ref?: string, all?: boolean } = {}): Promise<void> {
async fetch(options: { remote?: string, ref?: string, all?: boolean, prune?: boolean } = {}): Promise<void> {
const args = ['fetch'];
if (options.remote) {
......@@ -1172,6 +1172,11 @@ export class Repository {
args.push('--all');
}
if (options.prune) {
args.push('-p');
}
try {
await this.run(args);
} catch (err) {
......
......@@ -907,6 +907,11 @@ export class Repository implements Disposable {
await this.run(Operation.Fetch, () => this.repository.fetch());
}
@throttle
async fetchPrune(): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch({ prune: true }));
}
@throttle
async fetchAll(): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch({ all: true }));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册