Skip to content

Commit e20ec55

Browse files
committed
Removes branches remote commands if no remotes
Removes branch remote commands if not tracked
1 parent f911447 commit e20ec55

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,12 +1526,12 @@
15261526
"view/item/context": [
15271527
{
15281528
"command": "gitlens.openBranchesInRemote",
1529-
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branches",
1529+
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branches:remote",
15301530
"group": "1_gitlens@1"
15311531
},
15321532
{
15331533
"command": "gitlens.openBranchInRemote",
1534-
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branch-history",
1534+
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branch-history:remote",
15351535
"group": "1_gitlens@1"
15361536
},
15371537
{

src/views/branchHistoryNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class BranchHistoryNode extends ExplorerNode {
2727
name += ` ${GlyphChars.Space}${GlyphChars.ArrowLeftRight}${GlyphChars.Space} ${this.branch.tracking}`;
2828
}
2929
const item = new TreeItem(`${this.branch!.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`, TreeItemCollapsibleState.Collapsed);
30-
item.contextValue = this.resourceType;
30+
item.contextValue = this.branch.tracking ? `${this.resourceType}:remote` : this.resourceType;
3131

3232
item.iconPath = {
3333
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),

src/views/branchesNode.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ export class BranchesNode extends ExplorerNode {
2121
return [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchHistoryNode(b, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
2222
}
2323

24-
getTreeItem(): TreeItem {
24+
async getTreeItem(): Promise<TreeItem> {
2525
const item = new TreeItem(`Branches`, TreeItemCollapsibleState.Expanded);
26-
item.contextValue = this.resourceType;
26+
27+
const remotes = await this.git.getRemotes(this.uri.repoPath!);
28+
item.contextValue = (remotes !== undefined && remotes.length > 0)
29+
? `${this.resourceType}:remote`
30+
: this.resourceType;
2731

2832
item.iconPath = {
2933
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),

0 commit comments

Comments
 (0)