Skip to content

Commit

Permalink
Removes branches remote commands if no remotes
Browse files Browse the repository at this point in the history
Removes branch remote commands if not tracked
  • Loading branch information
eamodio committed Sep 12, 2017
1 parent f911447 commit e20ec55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1526,12 +1526,12 @@
"view/item/context": [
{
"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"
},
{
"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"
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/views/branchHistoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class BranchHistoryNode extends ExplorerNode {
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.contextValue = this.branch.tracking ? `${this.resourceType}:remote` : this.resourceType;

item.iconPath = {
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),
Expand Down
8 changes: 6 additions & 2 deletions src/views/branchesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))];
}

getTreeItem(): TreeItem {
async getTreeItem(): Promise<TreeItem> {
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 = {
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),
Expand Down

0 comments on commit e20ec55

Please sign in to comment.