diff --git a/src/views/nodes/repositoriesNode.ts b/src/views/nodes/repositoriesNode.ts index 2da9d4b..03efae9 100644 --- a/src/views/nodes/repositoriesNode.ts +++ b/src/views/nodes/repositoriesNode.ts @@ -1,5 +1,5 @@ 'use strict'; -import { Disposable, TextEditor, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; +import { Disposable, ProgressLocation, TextEditor, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import { Container } from '../../container'; import { GitUri } from '../../git/gitService'; import { Logger } from '../../logger'; @@ -59,11 +59,29 @@ export class RepositoriesNode extends SubscribeableExplorerNode { async fetchAll() { if (this._children === undefined || this._children.length === 0) return; - for (const node of this._children) { - if (node instanceof MessageNode) continue; - - await node.fetch(); - } + const children = this._children; + await window.withProgress( + { + location: ProgressLocation.Notification, + title: `Fetching repositories`, + cancellable: false + }, + async progress => { + const total = children.length + 1; + let i = 0; + for (const node of children) { + if (node instanceof MessageNode) continue; + + i++; + progress.report({ + message: `${node.repo.formattedName}...`, + increment: (i / total) * 100 + }); + + await node.fetch(false); + } + } + ); } async refresh() { diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index 3e7633a..f13a868 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -1,7 +1,7 @@ 'use strict'; import * as fs from 'fs'; import * as path from 'path'; -import { commands, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode'; +import { commands, Disposable, ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { @@ -168,21 +168,60 @@ export class RepositoryNode extends SubscribeableExplorerNode { return item; } - async fetch() { + async fetch(progress: boolean = true) { + if (!progress) return this.fetchCore(); + + await window.withProgress( + { + location: ProgressLocation.Notification, + title: `Fetching ${this.repo.formattedName}...`, + cancellable: false + }, + () => this.fetchCore() + ); + } + + private async fetchCore() { await commands.executeCommand('git.fetch', this.repo.path); await this.updateLastFetched(); this.explorer.triggerNodeUpdate(this); } - async pull() { + async pull(progress: boolean = true) { + if (!progress) return this.pullCore(); + + await window.withProgress( + { + location: ProgressLocation.Notification, + title: `Pulling ${this.repo.formattedName}...`, + cancellable: false + }, + () => this.pullCore() + ); + } + + private async pullCore() { await commands.executeCommand('git.pull', this.repo.path); await this.updateLastFetched(); this.explorer.triggerNodeUpdate(this); } - async push() { + async push(progress: boolean = true) { + if (!progress) return this.pushCore(); + + await window.withProgress( + { + location: ProgressLocation.Notification, + title: `Pushing ${this.repo.formattedName}...`, + cancellable: false + }, + () => this.pushCore() + ); + } + + private async pushCore() { await commands.executeCommand('git.push', this.repo.path); this.explorer.triggerNodeUpdate(this);