File tree Expand file tree Collapse file tree 4 files changed +137
-96
lines changed Expand file tree Collapse file tree 4 files changed +137
-96
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { getUpstreamStatus } from '../utils/status.utils';
1919import type { PullRequest , PullRequestState } from './pullRequest' ;
2020import type { GitBranchReference } from './reference' ;
2121import type { GitRemote } from './remote' ;
22+ import type { GitWorktree } from './worktree' ;
2223
2324export function isBranch ( branch : unknown ) : branch is GitBranch {
2425 return branch instanceof GitBranch ;
@@ -174,6 +175,14 @@ export class GitBranch implements GitBranchReference {
174175 return getUpstreamStatus ( this . upstream , options ) ;
175176 }
176177
178+ @debug ( )
179+ async getWorktree ( ) : Promise < GitWorktree | undefined > {
180+ if ( this . worktree == null ) return undefined ;
181+
182+ const worktreePath = this . worktree . path ;
183+ return this . container . git . worktrees ( this . repoPath ) ?. getWorktree ( wt => wt . path === worktreePath ) ;
184+ }
185+
177186 get starred ( ) : boolean {
178187 const starred = this . container . storage . getWorkspace ( 'starred:branches' ) ;
179188 return starred !== undefined && starred [ this . id ] === true ;
Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/no-restricted-imports */ /* TODO need to deal with sharing rich class shapes to webviews */
22import type { Uri , WorkspaceFolder } from 'vscode' ;
33import { workspace } from 'vscode' ;
4+ import { Schemes } from '../../constants' ;
45import type { Container } from '../../container' ;
56import { relative } from '../../system/-webview/path' ;
67import { getWorkspaceFriendlyPath } from '../../system/-webview/vscode' ;
@@ -28,6 +29,10 @@ export class GitWorktree {
2829 return this . branch ?. date ;
2930 }
3031
32+ get path ( ) : string {
33+ return this . uri . scheme === Schemes . File ? normalizePath ( this . uri . fsPath ) : this . uri . toString ( ) ;
34+ }
35+
3136 @memoize ( )
3237 get friendlyPath ( ) : string {
3338 const folder = this . workspaceFolder ;
You can’t perform that action at this time.
0 commit comments