Przeglądaj źródła

Adds variable expansion for worktree location

main
Eric Amodio 2 lat temu
rodzic
commit
41eb4b83e8
3 zmienionych plików z 20 dodań i 5 usunięć
  1. +4
    -0
      CHANGELOG.md
  2. +7
    -3
      src/commands/git/worktree.ts
  3. +9
    -2
      src/env/node/git/localGitProvider.ts

+ 4
- 0
CHANGELOG.md Wyświetl plik

@ -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

+ 7
- 3
src/commands/git/worktree.ts Wyświetl plik

@ -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;
}

+ 9
- 2
src/env/node/git/localGitProvider.ts Wyświetl plik

@ -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()

Ładowanie…
Anuluj
Zapisz