Adds remote tracking branch to custom view

Adds setting to show remote tracking branch in custom view
This commit is contained in:
Eric Amodio
2017-09-04 01:36:38 -04:00
parent a5af318269
commit 5a42ce4ed4
6 changed files with 26 additions and 18 deletions

View File

@@ -299,6 +299,7 @@ export interface IConfig {
gitExplorer: {
view: GitExplorerView;
showTrackingBranch: boolean;
commitFormat: string;
commitFileFormat: string;
stashFormat: string;

View File

@@ -4,13 +4,13 @@ import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitNode } from './commitNode';
import { GlyphChars } from '../constants';
import { ExplorerNode, ResourceType } from './explorerNode';
import { GitBranch, GitRemote, GitService, GitUri } from '../gitService';
import { GitBranch, GitService, GitUri } from '../gitService';
export class BranchHistoryNode extends ExplorerNode {
readonly resourceType: ResourceType = 'gitlens:branch-history';
constructor(public readonly branch: GitBranch, private readonly remote: GitRemote | undefined, uri: GitUri, private readonly template: string, protected readonly context: ExtensionContext, protected readonly git: GitService) {
constructor(public readonly branch: GitBranch, uri: GitUri, private readonly template: string, protected readonly context: ExtensionContext, protected readonly git: GitService) {
super(uri);
}
@@ -22,10 +22,11 @@ export class BranchHistoryNode extends ExplorerNode {
}
async getTreeItem(): Promise<TreeItem> {
const name = this.remote !== undefined
? this.branch.name.substring(this.remote.name.length + 1)
: this.branch.name;
const item = new TreeItem(`${name}${this.branch!.current ? ` ${GlyphChars.Space} ${GlyphChars.Check}` : ''}`, TreeItemCollapsibleState.Collapsed);
let name = this.branch.getName();
if (!this.branch.remote && this.branch.tracking !== undefined && this.git.config.gitExplorer.showTrackingBranch) {
name += ` ${GlyphChars.Space}${GlyphChars.ArrowLeftRight}${GlyphChars.Space} ${this.branch.tracking}`;
}
const item = new TreeItem(`${this.branch!.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`, TreeItemCollapsibleState.Collapsed);
item.contextValue = this.resourceType;
item.iconPath = {

View File

@@ -18,7 +18,7 @@ export class BranchesNode extends ExplorerNode {
if (branches === undefined) return [];
branches.sort((a, b) => (a.current ? -1 : 1) - (b.current ? -1 : 1) || a.name.localeCompare(b.name));
return [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchHistoryNode(b, undefined, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
return [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchHistoryNode(b, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
}
getTreeItem(): TreeItem {

View File

@@ -18,7 +18,7 @@ export class RemoteNode extends ExplorerNode {
if (branches === undefined) return [];
branches.sort((a, b) => a.name.localeCompare(b.name));
return [...Iterables.filterMap(branches, b => !b.remote || !b.name.startsWith(this.remote.name) ? undefined : new BranchHistoryNode(b, this.remote, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
return [...Iterables.filterMap(branches, b => !b.remote || !b.name.startsWith(this.remote.name) ? undefined : new BranchHistoryNode(b, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
}
getTreeItem(): TreeItem {