mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 02:58:32 -05:00
Combines same url into same remote Adds a change event for custom remote providers Adds a repo change event for custom remote providers
36 lines
1.4 KiB
TypeScript
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;
|
|
}
|
|
}
|