From f5586aa22d1413f8319e9c5ba527cc6966877dab Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Sat, 1 Jul 2023 10:45:49 +0200 Subject: [PATCH] api for deleting a vbranch --- src/routes/repo/[projectId]/vbranches.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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'); + }); +}