From bd74717e10fb36e19893c15941876b2383b94714 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 6 Feb 2025 00:05:57 +0100 Subject: Add DELETE command for review Only the owner or a maintainer of the project can remove a review. Removing a review also removes the git branch. Only reviews that are either draft or dropped can be removed. --- server/src/git_root.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'server/src/git_root.rs') diff --git a/server/src/git_root.rs b/server/src/git_root.rs index 31e4d45..f818495 100644 --- a/server/src/git_root.rs +++ b/server/src/git_root.rs @@ -62,6 +62,20 @@ impl Roots { Ok(()) } + + pub async fn del_branch(&self, project_id: &str, branch: &str) -> Result<(), git::Error> { + let repo; + { + let data = self.data.lock().unwrap(); + if let Some(tmp_repo) = data.project_repo.get(project_id) { + repo = tmp_repo.clone(); + } else { + return Ok(()); + } + } + + repo.delete_branch(branch).await + } } #[derive(Debug)] -- cgit v1.2.3-70-g09d2