Browse Source

Adds progress notification to fetch, pull, push ops

main
Eric Amodio 6 years ago
parent
commit
453dc0c5d9
2 changed files with 67 additions and 10 deletions
  1. +24
    -6
      src/views/nodes/repositoriesNode.ts
  2. +43
    -4
      src/views/nodes/repositoryNode.ts

+ 24
- 6
src/views/nodes/repositoriesNode.ts View File

@ -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() {

+ 43
- 4
src/views/nodes/repositoryNode.ts View File

@ -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);

Loading…
Cancel
Save