diff --git a/CHANGELOG.md b/CHANGELOG.md index a90222b..f6d626d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds stats (additions & deletions) to files nodes in comparisons — closes [#2078](https://github.com/gitkraken/vscode-gitlens/issues/2078) thanks to help via [PR #2079](https://github.com/gitkraken/vscode-gitlens/pull/2079) by Nafiur Rahman Khadem ([@ShafinKhadem](https://github.com/ShafinKhadem)) - Adds the ability to uniquely format uncommitted changes for the current line blame annotations — closes [#1987](https://github.com/gitkraken/vscode-gitlens/issues/1987) - Adds a `gitlens.currentLine.uncommittedChangesFormat` setting to specify the uncommitted changes format of the current line blame annotation. **NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes +- Adds variable expansion support to the `gitlens.worktrees.defaultLocation` setting + - `${userHome}` — the path of the user's home folder + - `${workspaceFolder}` — the path of the folder opened in VS Code containing the specified repository + - `${workspaceFolderBasename}` — the name of the folder opened in VS Code containing the specified repository without any slashes (/) ### Changed diff --git a/src/commands/git/worktree.ts b/src/commands/git/worktree.ts index b7c265c..c23dbca 100644 --- a/src/commands/git/worktree.ts +++ b/src/commands/git/worktree.ts @@ -478,14 +478,18 @@ export class WorktreeGitCommand extends QuickCommand { let recommendedRootUri; const repoUri = state.repo.uri; + const trailer = `${basename(repoUri.path)}.worktrees`; + if (repoUri.toString() !== pickedUri.toString()) { if (isDescendent(pickedUri, repoUri)) { - recommendedRootUri = Uri.joinPath(repoUri, '..', `${basename(repoUri.path)}.worktrees`); + recommendedRootUri = Uri.joinPath(repoUri, '..', trailer); + } else if (basename(pickedUri.path) === trailer) { + recommendedRootUri = pickedUri; } else { - recommendedRootUri = Uri.joinPath(pickedUri, `${basename(repoUri.path)}.worktrees`); + recommendedRootUri = Uri.joinPath(pickedUri, trailer); } } else { - recommendedRootUri = Uri.joinPath(repoUri, '..', `${basename(repoUri.path)}.worktrees`); + recommendedRootUri = Uri.joinPath(repoUri, '..', trailer); // Don't allow creating directly into the main worktree folder canCreateDirectlyInPicked = false; } diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index e9dd556..df42c35 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -110,7 +110,7 @@ import { } from '../../../system/path'; import type { PromiseOrValue } from '../../../system/promise'; import { any, fastestSettled, getSettledValue } from '../../../system/promise'; -import { equalsIgnoreCase, getDurationMilliseconds, md5, splitSingle } from '../../../system/string'; +import { equalsIgnoreCase, getDurationMilliseconds, interpolate, md5, splitSingle } from '../../../system/string'; import { PathTrie } from '../../../system/trie'; import { compare, fromString } from '../../../system/version'; import type { CachedBlame, CachedDiff, CachedLog, TrackedDocument } from '../../../trackers/gitDocumentTracker'; @@ -3930,7 +3930,14 @@ export class LocalGitProvider implements GitProvider, Disposable { location = joinPaths(homedir(), location.slice(1)); } - return this.getAbsoluteUri(location, repoPath); //isAbsolute(location) ? GitUri.file(location) : ; + const folder = this.container.git.getRepository(repoPath)?.folder; + location = interpolate(location, { + userHome: homedir(), + workspaceFolder: folder?.uri.fsPath, + workspaceFolderBasename: folder?.name, + }); + + return this.getAbsoluteUri(location, repoPath); } @log()