feat(git): Add comprehensive worktree management capabilities
This update introduces full support for Git worktrees, allowing users to manage multiple isolated working copies within a single repository. This includes new functionality to list, add, remove, move, lock, and repair worktrees, significantly enhancing the repository's capability to handle parallel development streams. - Added `GitWorktree` structure definition across API contracts and Rust backend - Implemented full CRUD operations for worktrees in Tauri commands - Updated UI components (App.svelte, BranchPanel.svelte) to expose worktree management dialog
This commit is contained in:
@@ -21,6 +21,7 @@ import type {
|
||||
GitStash,
|
||||
GitStatus,
|
||||
GitTag,
|
||||
GitWorktree,
|
||||
LocalModelOption,
|
||||
PatchApplyAction,
|
||||
RepositoryBundle,
|
||||
@@ -116,6 +117,56 @@ export function deleteBranch(path: string, branch: string, force = false): Promi
|
||||
return invoke<GitStatus>("delete_branch", { path, branch, force });
|
||||
}
|
||||
|
||||
export function listWorktrees(path: string): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("list_worktrees", { path });
|
||||
}
|
||||
|
||||
export function addWorktree(
|
||||
path: string,
|
||||
worktreePath: string,
|
||||
options: {
|
||||
branch?: string;
|
||||
newBranch?: string;
|
||||
startPoint?: string;
|
||||
detached?: boolean;
|
||||
lock?: boolean;
|
||||
} = {},
|
||||
): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("add_worktree", {
|
||||
path,
|
||||
worktreePath,
|
||||
branch: options.branch ?? null,
|
||||
newBranch: options.newBranch ?? null,
|
||||
startPoint: options.startPoint ?? null,
|
||||
detached: options.detached ?? false,
|
||||
lock: options.lock ?? false,
|
||||
});
|
||||
}
|
||||
|
||||
export function removeWorktree(path: string, worktreePath: string, force = false): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("remove_worktree", { path, worktreePath, force });
|
||||
}
|
||||
|
||||
export function moveWorktree(path: string, worktreePath: string, destination: string): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("move_worktree", { path, worktreePath, destination });
|
||||
}
|
||||
|
||||
export function lockWorktree(path: string, worktreePath: string, reason?: string): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("lock_worktree", { path, worktreePath, reason: reason?.trim() || null });
|
||||
}
|
||||
|
||||
export function unlockWorktree(path: string, worktreePath: string): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("unlock_worktree", { path, worktreePath });
|
||||
}
|
||||
|
||||
export function pruneWorktrees(path: string): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("prune_worktrees", { path });
|
||||
}
|
||||
|
||||
export function repairWorktree(path: string, worktreePath: string): Promise<GitWorktree[]> {
|
||||
return invoke<GitWorktree[]>("repair_worktree", { path, worktreePath });
|
||||
}
|
||||
|
||||
export function listTags(path: string): Promise<GitTag[]> {
|
||||
return invoke<GitTag[]>("list_tags", { path });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user