Files
vscode-gitlens/src/views/remotesNode.ts
Eric Amodio ccc29e3dfc Reworks remote parsing
Combines same url into same remote
Adds a change event for custom remote providers
Adds a repo change event for custom remote providers
2017-09-12 15:46:44 -04:00

36 lines
1.4 KiB
TypeScript

'use strict';
import { Iterables } from '../system';
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ExplorerNode, MessageNode, ResourceType } from './explorerNode';
import { GitService, GitUri } from '../gitService';
import { RemoteNode } from './remoteNode';
export class RemotesNode extends ExplorerNode {
readonly resourceType: ResourceType = 'gitlens:remotes';
constructor(uri: GitUri, protected readonly context: ExtensionContext, protected readonly git: GitService) {
super(uri);
}
async getChildren(): Promise<ExplorerNode[]> {
const remotes = await this.git.getRemotes(this.uri.repoPath!);
if (remotes === undefined || remotes.length === 0) return [new MessageNode('No remotes configured')];
remotes.sort((a, b) => a.name.localeCompare(b.name));
return [...Iterables.map(remotes, r => new RemoteNode(r, this.uri, this.context, this.git))];
}
getTreeItem(): TreeItem {
const item = new TreeItem(`Remotes`, TreeItemCollapsibleState.Collapsed);
item.contextValue = this.resourceType;
item.iconPath = {
dark: this.context.asAbsolutePath('images/dark/icon-remote.svg'),
light: this.context.asAbsolutePath('images/light/icon-remote.svg')
};
return item;
}
}