Removes branches remote commands if no remotes

Removes branch remote commands if not tracked
This commit is contained in:
Eric Amodio
2017-09-11 23:41:47 -04:00
parent f911447c5e
commit e20ec552b7
3 changed files with 9 additions and 5 deletions

View File

@@ -1526,12 +1526,12 @@
"view/item/context": [ "view/item/context": [
{ {
"command": "gitlens.openBranchesInRemote", "command": "gitlens.openBranchesInRemote",
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branches", "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branches:remote",
"group": "1_gitlens@1" "group": "1_gitlens@1"
}, },
{ {
"command": "gitlens.openBranchInRemote", "command": "gitlens.openBranchInRemote",
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branch-history", "when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branch-history:remote",
"group": "1_gitlens@1" "group": "1_gitlens@1"
}, },
{ {

View File

@@ -27,7 +27,7 @@ export class BranchHistoryNode extends ExplorerNode {
name += ` ${GlyphChars.Space}${GlyphChars.ArrowLeftRight}${GlyphChars.Space} ${this.branch.tracking}`; name += ` ${GlyphChars.Space}${GlyphChars.ArrowLeftRight}${GlyphChars.Space} ${this.branch.tracking}`;
} }
const item = new TreeItem(`${this.branch!.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`, TreeItemCollapsibleState.Collapsed); const item = new TreeItem(`${this.branch!.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`, TreeItemCollapsibleState.Collapsed);
item.contextValue = this.resourceType; item.contextValue = this.branch.tracking ? `${this.resourceType}:remote` : this.resourceType;
item.iconPath = { item.iconPath = {
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'), dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),

View File

@@ -21,9 +21,13 @@ export class BranchesNode extends ExplorerNode {
return [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchHistoryNode(b, 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 { async getTreeItem(): Promise<TreeItem> {
const item = new TreeItem(`Branches`, TreeItemCollapsibleState.Expanded); const item = new TreeItem(`Branches`, TreeItemCollapsibleState.Expanded);
item.contextValue = this.resourceType;
const remotes = await this.git.getRemotes(this.uri.repoPath!);
item.contextValue = (remotes !== undefined && remotes.length > 0)
? `${this.resourceType}:remote`
: this.resourceType;
item.iconPath = { item.iconPath = {
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'), dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),