fix: handle case when branch is not found in delete_branch function

This commit is contained in:
Nikita Galaiko 2023-12-12 14:43:37 +01:00 committed by GitButler
parent 0d667c1fa3
commit f5331b4c1e

View File

@ -1357,9 +1357,12 @@ pub fn delete_branch(
let branch_reader = branch::Reader::new(&current_session_reader);
let branch_writer = branch::Writer::new(gb_repository);
let branch = branch_reader
.read(branch_id)
.context("failed to read branch")?;
let branch = match branch_reader.read(branch_id) {
Ok(branch) => Ok(branch),
Err(reader::Error::NotFound) => return Ok(()),
Err(error) => Err(error),
}
.context("failed to read branch")?;
if branch.applied && unapply_branch(gb_repository, project_repository, branch_id)?.is_none() {
return Ok(());