瀏覽代碼

Changes fetch/pull/push to be in parallel

main
Eric Amodio 5 年之前
父節點
當前提交
53bcea2500
共有 2 個檔案被更改,包括 39 行新增57 行删除
  1. +36
    -51
      src/git/gitService.ts
  2. +3
    -6
      src/git/models/repository.ts

+ 36
- 51
src/git/gitService.ts 查看文件

@ -510,85 +510,70 @@ export class GitService implements Disposable {
@gate()
@log()
async fetchAll() {
const repositories = await this.getOrderedRepositories();
async fetchAll(repositories?: Repository[]) {
if (repositories === undefined) {
repositories = await this.getOrderedRepositories();
}
if (repositories.length === 0) return;
if (repositories.length === 1) {
repositories[0].fetch();
return;
}
await window.withProgress(
{
location: ProgressLocation.Notification,
title: 'Fetching repositories',
cancellable: true
title: `Fetching ${repositories.length} repositories`
},
async (progress, token) => {
const total = repositories.length;
for (const repo of repositories) {
progress.report({
message: `${repo.formattedName}...`,
increment: 100 / total
});
if (token.isCancellationRequested) break;
await repo.fetch({ progress: false });
}
}
() => Promise.all(repositories!.map(r => r.fetch({ progress: false })))
);
}
@gate()
@log()
async pullAll() {
const repositories = await this.getOrderedRepositories();
async pullAll(repositories?: Repository[]) {
if (repositories === undefined) {
repositories = await this.getOrderedRepositories();
}
if (repositories.length === 0) return;
if (repositories.length === 1) {
repositories[0].pull();
return;
}
await window.withProgress(
{
location: ProgressLocation.Notification,
title: 'Pulling repositories',
cancellable: true
title: `Pulling ${repositories.length} repositories`
},
async (progress, token) => {
const total = repositories.length;
for (const repo of repositories) {
progress.report({
message: `${repo.formattedName}...`,
increment: 100 / total
});
if (token.isCancellationRequested) break;
await repo.pull({ progress: false });
}
}
() => Promise.all(repositories!.map(r => r.pull({ progress: false })))
);
}
@gate()
@log()
async pushAll() {
const repositories = await this.getOrderedRepositories();
async pushAll(repositories?: Repository[]) {
if (repositories === undefined) {
repositories = await this.getOrderedRepositories();
}
if (repositories.length === 0) return;
if (repositories.length === 1) {
repositories[0].push();
return;
}
await window.withProgress(
{
location: ProgressLocation.Notification,
title: 'Pushing repositories',
cancellable: true
title: `Pushing ${repositories.length} repositories`
},
async (progress, token) => {
const total = repositories.length;
for (const repo of repositories) {
progress.report({
message: `${repo.formattedName}...`,
increment: 100 / total
});
if (token.isCancellationRequested) break;
await repo.push({ progress: false });
}
}
() => Promise.all(repositories!.map(r => r.push({ progress: false })))
);
}

+ 3
- 6
src/git/models/repository.ts 查看文件

@ -244,8 +244,7 @@ export class Repository implements Disposable {
return void (await window.withProgress(
{
location: ProgressLocation.Notification,
title: `Fetching ${opts.remote ? `${opts.remote} of ` : ''}${this.formattedName}...`,
cancellable: false
title: `Fetching ${opts.remote ? `${opts.remote} of ` : ''}${this.formattedName}...`
},
() => this.fetchCore(opts)
));
@ -332,8 +331,7 @@ export class Repository implements Disposable {
return void (await window.withProgress(
{
location: ProgressLocation.Notification,
title: `Pulling ${this.formattedName}...`,
cancellable: false
title: `Pulling ${this.formattedName}...`
},
() => this.pullCore()
));
@ -360,8 +358,7 @@ export class Repository implements Disposable {
return void (await window.withProgress(
{
location: ProgressLocation.Notification,
title: `Pushing ${this.formattedName}...`,
cancellable: false
title: `Pushing ${this.formattedName}...`
},
() => this.pushCore(force)
));

Loading…
取消
儲存