Add worktree command (#255945)

* Basic functionality of adding worktree

* Code refactoring and clean up

* Remove accidentally added submodules

* Specify folder destination

* Remove default worktree path, always prompt for destination instead

* create worktree only displayed in repo's worktree subcommands

* Git - handle another error condition when detecting worktrees (#256278)

* Rework creating worktree flow

* Include worktree name placeholder

---------

Co-authored-by: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com>
This commit is contained in:
Christy 😺
2025-07-16 11:54:45 -07:00
committed by GitHub
parent b9e82f6b60
commit 72aaf2bc9f
6 changed files with 102 additions and 3 deletions

View File

@@ -64,6 +64,7 @@ export const enum OperationKind {
SubmoduleUpdate = 'SubmoduleUpdate',
Sync = 'Sync',
Tag = 'Tag',
Worktree = 'Worktree'
}
export type Operation = AddOperation | ApplyOperation | BlameOperation | BranchOperation | CheckIgnoreOperation | CherryPickOperation |
@@ -74,7 +75,7 @@ export type Operation = AddOperation | ApplyOperation | BlameOperation | BranchO
MergeBaseOperation | MoveOperation | PostCommitCommandOperation | PullOperation | PushOperation | RemoteOperation | RenameBranchOperation |
RemoveOperation | ResetOperation | RebaseOperation | RebaseAbortOperation | RebaseContinueOperation | RefreshOperation | RevertFilesOperation |
RevListOperation | RevParseOperation | SetBranchUpstreamOperation | ShowOperation | StageOperation | StatusOperation | StashOperation |
SubmoduleUpdateOperation | SyncOperation | TagOperation;
SubmoduleUpdateOperation | SyncOperation | TagOperation | WorktreeOperation;
type BaseOperation = { kind: OperationKind; blocking: boolean; readOnly: boolean; remote: boolean; retry: boolean; showProgress: boolean };
export type AddOperation = BaseOperation & { kind: OperationKind.Add };
@@ -134,6 +135,7 @@ export type StashOperation = BaseOperation & { kind: OperationKind.Stash };
export type SubmoduleUpdateOperation = BaseOperation & { kind: OperationKind.SubmoduleUpdate };
export type SyncOperation = BaseOperation & { kind: OperationKind.Sync };
export type TagOperation = BaseOperation & { kind: OperationKind.Tag };
export type WorktreeOperation = BaseOperation & { kind: OperationKind.Worktree };
export const Operation = {
Add: (showProgress: boolean): AddOperation => ({ kind: OperationKind.Add, blocking: false, readOnly: false, remote: false, retry: false, showProgress }),
@@ -192,7 +194,8 @@ export const Operation = {
Stash: { kind: OperationKind.Stash, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as StashOperation,
SubmoduleUpdate: { kind: OperationKind.SubmoduleUpdate, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as SubmoduleUpdateOperation,
Sync: { kind: OperationKind.Sync, blocking: true, readOnly: false, remote: true, retry: true, showProgress: true } as SyncOperation,
Tag: { kind: OperationKind.Tag, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as TagOperation
Tag: { kind: OperationKind.Tag, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as TagOperation,
Worktree: { kind: OperationKind.Worktree, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as WorktreeOperation
};
export interface OperationResult {