From acef1ad05e93a28068fd71cc41369dc199441521 Mon Sep 17 00:00:00 2001 From: chris Mitchell Date: Wed, 18 Sep 2024 11:19:22 -0400 Subject: [PATCH] Protect main branch --- src/models/operations.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/models/operations.rs b/src/models/operations.rs index 2710d02..629a268 100644 --- a/src/models/operations.rs +++ b/src/models/operations.rs @@ -288,6 +288,9 @@ impl Branch { } pub fn delete(conn: &Connection, db_uuid: &str, branch_name: &str) { + if branch_name == "main" { + panic!("Main branch cannot be deleted"); + } if let Some(branch) = Branch::get_by_name(conn, db_uuid, branch_name) { let branch_id = branch.id; if let Some(current_branch) = OperationState::get_current_branch(conn, db_uuid) {