Skip to content

Commit f5403fa

Browse files
committed
Fixes #3548 changes branch icon if in a worktree
1 parent 985ecc5 commit f5403fa

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1919

2020
### Fixed
2121

22+
- Fixes [#3548](https://github.com/gitkraken/vscode-gitlens/issues/3548) - Change the current branch icon on the Commit Graph to a worktree icon if its on a worktree
2223
- Fixes [#3592](https://github.com/gitkraken/vscode-gitlens/issues/3592) - Connecting to an integration via Remotes view (but likely others) doesn't work
2324
- Fixes [#3571](https://github.com/gitkraken/vscode-gitlens/issues/3571) - Gitlens fails to register buttons on top-right corner — thanks to [PR #3605](https://github.com/gitkraken/vscode-gitlens/pull/3605) by Jean Pierre ([@jeanp413](https://github.com/jeanp413))
2425
- Fixes an issue where virtual repositories for GitHub PRs from forks wouldn't load properly

src/plus/webviews/graph/graphWebview.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,6 +2361,9 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
23612361
if (branch != null) {
23622362
branchState = { ...branch.state };
23632363

2364+
const worktreesByBranch = data?.worktreesByBranch ?? (await getWorktreesByBranch(this.repository));
2365+
branchState.worktree = worktreesByBranch?.has(branch.id) ?? false;
2366+
23642367
if (branch.upstream != null) {
23652368
branchState.upstream = branch.upstream.name;
23662369

src/plus/webviews/graph/protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export interface BranchState extends GitTrackingState {
137137
url?: string;
138138
};
139139
pr?: PullRequestShape;
140+
worktree?: boolean;
140141
}
141142

142143
export type GraphWorkingTreeStats = WorkDirStats;

src/views/nodes/branchNode.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,16 +422,23 @@ export class BranchNode
422422
const worktree = this.worktree;
423423
const status = this.branch.status;
424424

425+
const suffixes = [];
426+
if (this.current) {
427+
if (this.branch.rebasing) {
428+
suffixes.push('rebasing');
429+
}
430+
suffixes.push('current branch');
431+
}
432+
if (worktree) {
433+
if (worktree.opened && !this.current) {
434+
suffixes.push('in an opened worktree');
435+
} else {
436+
suffixes.push('in a worktree');
437+
}
438+
}
439+
425440
let tooltip: string | MarkdownString = `$(git-branch) \`${this.branch.getNameWithoutRemote()}\`${
426-
this.current
427-
? this.branch.rebasing
428-
? ' \u00a0(_current, rebasing_)'
429-
: ' \u00a0(_current_)'
430-
: worktree?.opened
431-
? ' \u00a0(_worktree, opened_)'
432-
: worktree
433-
? ' \u00a0(_worktree_)'
434-
: ''
441+
suffixes.length ? ` \u00a0(_${suffixes.join(', ')}_)` : ''
435442
}`;
436443

437444
let contextValue: string = ContextValues.Branch;

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,14 @@ export function GraphWrapper({
12361236
aria-label="Switch to Another Branch..."
12371237
>
12381238
{!branchState?.pr ? (
1239-
<span className="codicon codicon-git-branch" aria-hidden="true"></span>
1239+
branchState?.worktree ? (
1240+
<span
1241+
className="glicon glicon-repositories-view"
1242+
aria-hidden="true"
1243+
></span>
1244+
) : (
1245+
<span className="codicon codicon-git-branch" aria-hidden="true"></span>
1246+
)
12401247
) : (
12411248
''
12421249
)}
@@ -1252,6 +1259,7 @@ export function GraphWrapper({
12521259
<hr />
12531260
<span className="codicon codicon-git-branch" aria-hidden="true"></span>{' '}
12541261
<span className="md-code">{branchName}</span>
1262+
{branchState?.worktree ? <i> (in a worktree)</i> : ''}
12551263
</span>
12561264
</div>
12571265
</GlPopover>

0 commit comments

Comments
 (0)