diff --git a/src/routes/repo/[projectId]/vbranches.ts b/src/routes/repo/[projectId]/vbranches.ts index 3b91881db..ffcf90ae7 100644 --- a/src/routes/repo/[projectId]/vbranches.ts +++ b/src/routes/repo/[projectId]/vbranches.ts @@ -19,6 +19,7 @@ export interface VirtualBranchOperations { unapplyBranch(branchId: string): Promise; updateBranchOwnership(branchId: string, ownership: string): Promise; pushBranch(branchId: string): Promise; + deleteBranch(branchId: string): Promise; } export function getVirtualBranches( @@ -42,7 +43,8 @@ export function getVirtualBranches( unapplyBranch: (branchId) => unapplyBranch(writeable, projectId, branchId), updateBranchOwnership: (branchId, ownership) => updateBranchOwnership(writeable, projectId, branchId, ownership), - pushBranch: (branchId) => pushBranch(writeable, projectId, branchId) + pushBranch: (branchId) => pushBranch(writeable, projectId, branchId), + deleteBranch: (branchId) => deleteBranch(writeable, projectId, branchId) }; cache.set(projectId, store); return store; @@ -225,3 +227,16 @@ function pushBranch(writable: Writable>, projectId: string, b error('Failed to push branch.'); }); } + +function deleteBranch(writable: Writable>, projectId: string, branchId: string) { + return invoke('delete_virtual_branch', { + projectId: projectId, + branchId: branchId + }) + .then(() => { + refresh(projectId, writable); + }) + .catch(() => { + error('Unable to delete branch'); + }); +}