mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 03:39:23 +00:00
Git - add worktrees node to the Repositories view (#284224)
* Worktree node - initial implementation * Wire up various commands
This commit is contained in:
@@ -8,8 +8,8 @@ import * as path from 'path';
|
||||
import { Command, commands, Disposable, MessageOptions, Position, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento, UIKind, QuickInputButton, ThemeIcon, SourceControlHistoryItem, SourceControl, InputBoxValidationMessage, Tab, TabInputNotebook, QuickInputButtonLocation, languages, SourceControlArtifact } from 'vscode';
|
||||
import TelemetryReporter from '@vscode/extension-telemetry';
|
||||
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
|
||||
import { ForcePushMode, GitErrorCodes, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote, Branch, Ref } from './api/git';
|
||||
import { Git, GitError, Stash, Worktree } from './git';
|
||||
import { ForcePushMode, GitErrorCodes, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote, Branch, Ref, Worktree } from './api/git';
|
||||
import { Git, GitError, Stash } from './git';
|
||||
import { Model } from './model';
|
||||
import { GitResourceGroup, Repository, Resource, ResourceGroupType } from './repository';
|
||||
import { DiffEditorSelectionHunkToolbarContext, LineChange, applyLineChanges, getIndexDiffInformation, getModifiedRange, getWorkingTreeDiffInformation, intersectDiffWithRange, invertLineChange, toLineChanges, toLineRanges, compareLineChanges } from './staging';
|
||||
@@ -3437,6 +3437,10 @@ export class CommandCenter {
|
||||
return;
|
||||
}
|
||||
|
||||
await this._createWorktree(repository);
|
||||
}
|
||||
|
||||
async _createWorktree(repository: Repository): Promise<void> {
|
||||
const config = workspace.getConfiguration('git');
|
||||
const branchPrefix = config.get<string>('branchPrefix')!;
|
||||
|
||||
@@ -5083,6 +5087,15 @@ export class CommandCenter {
|
||||
await this._createTag(repository);
|
||||
}
|
||||
|
||||
@command('git.repositories.createWorktree', { repository: true })
|
||||
async artifactGroupCreateWorktree(repository: Repository): Promise<void> {
|
||||
if (!repository) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this._createWorktree(repository);
|
||||
}
|
||||
|
||||
@command('git.repositories.checkout', { repository: true })
|
||||
async artifactCheckout(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
@@ -5293,6 +5306,35 @@ export class CommandCenter {
|
||||
await this._stashDrop(repository, parseInt(match[1]), artifact.name);
|
||||
}
|
||||
|
||||
@command('git.repositories.openWorktree', { repository: true })
|
||||
async artifactOpenWorktree(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uri = Uri.file(artifact.id);
|
||||
await commands.executeCommand('vscode.openFolder', uri, { forceReuseWindow: true });
|
||||
}
|
||||
|
||||
@command('git.repositories.openWorktreeInNewWindow', { repository: true })
|
||||
async artifactOpenWorktreeInNewWindow(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uri = Uri.file(artifact.id);
|
||||
await commands.executeCommand('vscode.openFolder', uri, { forceNewWindow: true });
|
||||
}
|
||||
|
||||
@command('git.repositories.deleteWorktree', { repository: true })
|
||||
async artifactDeleteWorktree(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
await repository.deleteWorktree(artifact.id);
|
||||
}
|
||||
|
||||
private createCommand(id: string, key: string, method: Function, options: ScmCommandOptions): (...args: any[]) => any {
|
||||
const result = (...args: any[]) => {
|
||||
let result: Promise<any>;
|
||||
|
||||
Reference in New Issue
Block a user