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

Add git.fetchPrune

上级 52caa1a4
...@@ -265,6 +265,11 @@ ...@@ -265,6 +265,11 @@
"title": "%command.fetch%", "title": "%command.fetch%",
"category": "Git" "category": "Git"
}, },
{
"command": "git.fetchPrune",
"title": "%command.fetchPrune%",
"category": "Git"
},
{ {
"command": "git.fetchAll", "command": "git.fetchAll",
"title": "%command.fetchAll%", "title": "%command.fetchAll%",
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
"command.merge": "Merge Branch...", "command.merge": "Merge Branch...",
"command.createTag": "Create Tag", "command.createTag": "Create Tag",
"command.fetch": "Fetch", "command.fetch": "Fetch",
"command.fetchPrune": "Fetch (prune)",
"command.fetchAll": "Fetch From All Remotes", "command.fetchAll": "Fetch From All Remotes",
"command.pull": "Pull", "command.pull": "Pull",
"command.pullRebase": "Pull (Rebase)", "command.pullRebase": "Pull (Rebase)",
......
...@@ -1539,6 +1539,17 @@ export class CommandCenter { ...@@ -1539,6 +1539,17 @@ export class CommandCenter {
await repository.fetchDefault(); 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 }) @command('git.fetchAll', { repository: true })
async fetchAll(repository: Repository): Promise<void> { async fetchAll(repository: Repository): Promise<void> {
if (repository.remotes.length === 0) { if (repository.remotes.length === 0) {
......
...@@ -1159,7 +1159,7 @@ export class Repository { ...@@ -1159,7 +1159,7 @@ export class Repository {
await this.run(args); 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']; const args = ['fetch'];
if (options.remote) { if (options.remote) {
...@@ -1172,6 +1172,11 @@ export class Repository { ...@@ -1172,6 +1172,11 @@ export class Repository {
args.push('--all'); args.push('--all');
} }
if (options.prune) {
args.push('-p');
}
try { try {
await this.run(args); await this.run(args);
} catch (err) { } catch (err) {
......
...@@ -907,6 +907,11 @@ export class Repository implements Disposable { ...@@ -907,6 +907,11 @@ export class Repository implements Disposable {
await this.run(Operation.Fetch, () => this.repository.fetch()); await this.run(Operation.Fetch, () => this.repository.fetch());
} }
@throttle
async fetchPrune(): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch({ prune: true }));
}
@throttle @throttle
async fetchAll(): Promise<void> { async fetchAll(): Promise<void> {
await this.run(Operation.Fetch, () => this.repository.fetch({ all: true })); 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.
先完成此消息的编辑!
想要评论请 注册