Skip to content

Commit d2f4884

Browse files
committed
Changes many Home actions to be stateless
Adds logging for Home actions
1 parent e32b707 commit d2f4884

File tree

4 files changed

+137
-96
lines changed

4 files changed

+137
-96
lines changed

src/git/models/branch.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { getUpstreamStatus } from '../utils/status.utils';
1919
import type { PullRequest, PullRequestState } from './pullRequest';
2020
import type { GitBranchReference } from './reference';
2121
import type { GitRemote } from './remote';
22+
import type { GitWorktree } from './worktree';
2223

2324
export 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;

src/git/models/worktree.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-restricted-imports */ /* TODO need to deal with sharing rich class shapes to webviews */
22
import type { Uri, WorkspaceFolder } from 'vscode';
33
import { workspace } from 'vscode';
4+
import { Schemes } from '../../constants';
45
import type { Container } from '../../container';
56
import { relative } from '../../system/-webview/path';
67
import { 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;

0 commit comments

Comments
 (0)