From 08e31f1fbc78b3137c83a555a8e5089d902befb8 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 1 Nov 2018 11:47:35 -0400 Subject: [PATCH] Executes multi-repo commands in order --- src/git/gitService.ts | 13 ++++++++++--- src/views/nodes/repositoriesNode.ts | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/git/gitService.ts b/src/git/gitService.ts index c53c832..e4d032a 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -473,7 +473,7 @@ export class GitService implements Disposable { @gate() @log() async fetchAll() { - const repositories = [...(await this.getRepositories())]; + const repositories = await this.getOrderedRepositories(); if (repositories.length === 0) return; await window.withProgress( @@ -503,7 +503,7 @@ export class GitService implements Disposable { @gate() @log() async pullAll() { - const repositories = [...(await this.getRepositories())]; + const repositories = await this.getOrderedRepositories(); if (repositories.length === 0) return; await window.withProgress( @@ -533,7 +533,7 @@ export class GitService implements Disposable { @gate() @log() async pushAll() { - const repositories = [...(await this.getRepositories())]; + const repositories = await this.getOrderedRepositories(); if (repositories.length === 0) return; await window.withProgress( @@ -1703,6 +1703,13 @@ export class GitService implements Disposable { return predicate !== undefined ? Iterables.filter(values, predicate) : values; } + async getOrderedRepositories(): Promise { + const repositories = [...(await this.getRepositories())]; + if (repositories.length === 0) return repositories; + + return repositories.sort((a, b) => a.index - b.index); + } + private async getRepositoryTree(): Promise> { if (this._repositoriesLoadingPromise !== undefined) { await this._repositoriesLoadingPromise; diff --git a/src/views/nodes/repositoriesNode.ts b/src/views/nodes/repositoriesNode.ts index 8c4fd17..3fe79b0 100644 --- a/src/views/nodes/repositoriesNode.ts +++ b/src/views/nodes/repositoriesNode.ts @@ -32,11 +32,11 @@ export class RepositoriesNode extends SubscribeableViewNode { async getChildren(): Promise { if (this._children === undefined) { - const repositories = [...(await Container.git.getRepositories())]; + const repositories = await Container.git.getOrderedRepositories(); if (repositories.length === 0) return [new MessageNode(this, 'No repositories could be found.')]; const children = []; - for (const repo of repositories.sort((a, b) => a.index - b.index)) { + for (const repo of repositories) { if (repo.closed) continue; children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, this.view)); @@ -62,7 +62,7 @@ export class RepositoriesNode extends SubscribeableViewNode { async refresh(reason?: RefreshReason) { if (this._children === undefined) return; - const repositories = [...(await Container.git.getRepositories())]; + const repositories = await Container.git.getOrderedRepositories(); if (repositories.length === 0 && (this._children === undefined || this._children.length === 0)) return; if (repositories.length === 0) { @@ -71,7 +71,7 @@ export class RepositoriesNode extends SubscribeableViewNode { } const children = []; - for (const repo of repositories.sort((a, b) => a.index - b.index)) { + for (const repo of repositories) { const normalizedPath = repo.normalizedPath; const child = (this._children as RepositoryNode[]).find(c => c.repo.normalizedPath === normalizedPath); if (child !== undefined) {