Skip to content

Commit 3ff23b0

Browse files
committed
Fixes creating worktrees
1 parent 05b287c commit 3ff23b0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: src/env/node/git/sub-providers/worktrees.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { exec } from 'child_process';
22
import { promises as fs } from 'fs';
33
import { homedir } from 'os';
4-
import type { Uri } from 'vscode';
4+
import { Uri } from 'vscode';
55
import type { Container } from '../../../../container';
66
import type { GitCache } from '../../../../git/cache';
77
import {
@@ -112,8 +112,20 @@ export class WorktreesGitSubProvider implements GitWorktreesSubProvider {
112112
}
113113

114114
@log()
115-
// eslint-disable-next-line @typescript-eslint/require-await
116115
async getWorktreesDefaultUri(repoPath: string): Promise<Uri | undefined> {
116+
let defaultUri = this.getWorktreesDefaultUriCore(repoPath);
117+
if (defaultUri != null) return defaultUri;
118+
119+
// If we don't have a default set, default it to the parent folder of the repo folder
120+
const repo = this.container.git.getRepository(repoPath);
121+
defaultUri = (await repo?.getCommonRepositoryUri()) ?? repo?.uri;
122+
if (defaultUri != null) {
123+
defaultUri = Uri.joinPath(defaultUri, '..');
124+
}
125+
return defaultUri;
126+
}
127+
128+
private getWorktreesDefaultUriCore(repoPath: string): Uri | undefined {
117129
let location = configuration.get('worktrees.defaultLocation');
118130
if (location == null) return undefined;
119131

0 commit comments

Comments
 (0)