diff --git a/src-tauri/src/gb_repository/repository.rs b/src-tauri/src/gb_repository/repository.rs index 666fbccc3..a17288ac5 100644 --- a/src-tauri/src/gb_repository/repository.rs +++ b/src-tauri/src/gb_repository/repository.rs @@ -388,8 +388,11 @@ impl Repository { return Err(anyhow!("project does not exist")); } let project = project.unwrap(); - let project_repository = project_repository::Repository::open(&project)?; - let session = self.create_current_session(&project_repository)?; + let project_repository = project_repository::Repository::open(&project) + .context("failed to open project repository")?; + let session = self + .create_current_session(&project_repository) + .context("failed to create current session")?; Ok(session) } } @@ -568,14 +571,14 @@ impl Repository { // calculate the commit as the merge-base between HEAD in project_repository and this target commit let head_oid = repo .head() - .expect("Failed to get HEAD reference") + .context("Failed to get HEAD reference")? .peel_to_commit() - .expect("Failed to peel HEAD reference to commit") + .context("Failed to peel HEAD reference to commit")? .id(); commit_oid = repo .merge_base(head_oid, commit_oid) - .expect("Failed to calculate merge base"); + .context("Failed to calculate merge base")?; println!("merge base: {:?}", commit_oid); } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ed6caba83..846be07c8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -446,9 +446,12 @@ async fn git_remote_branches( project_id: &str, ) -> Result, Error> { let app = handle.state::(); - let branches = app - .git_remote_branches(project_id) - .with_context(|| format!("failed to get git branches for project {}", project_id))?; + let branches = app.git_remote_branches(project_id).with_context(|| { + format!( + "failed to get remote git branches for project {}", + project_id + ) + })?; Ok(branches) } diff --git a/src-tauri/src/virtual_branches/mod.rs b/src-tauri/src/virtual_branches/mod.rs index 332200919..ca6efaa61 100644 --- a/src-tauri/src/virtual_branches/mod.rs +++ b/src-tauri/src/virtual_branches/mod.rs @@ -593,10 +593,10 @@ pub fn list_virtual_branches( let mut branches: Vec = Vec::new(); let current_session = gb_repository .get_or_create_current_session() - .expect("failed to get or create currnt session"); + .context("failed to get or create currnt session")?; let current_session_reader = sessions::Reader::open(gb_repository, ¤t_session) - .expect("failed to open current session reader"); + .context("failed to open current session reader")?; let target_reader = target::Reader::new(¤t_session_reader); let default_target = match target_reader.read_default() { @@ -1392,9 +1392,9 @@ pub fn get_status_by_branch( fn get_default_target(gb_repository: &gb_repository::Repository) -> Result { let current_session = gb_repository .get_or_create_current_session() - .expect("failed to get or create currnt session"); + .context("failed to get or create currnt session")?; let current_session_reader = sessions::Reader::open(gb_repository, ¤t_session) - .expect("failed to open current session reader"); + .context("failed to open current session reader")?; let target_reader = target::Reader::new(¤t_session_reader); let default_target = match target_reader.read_default() { @@ -1621,7 +1621,7 @@ fn write_tree( .to_object(git_repository) .unwrap() .peel_to_blob() - .expect("failed to get blob"); + .context("failed to get blob")?; // get the contents let blob_contents = blob.content(); @@ -1686,7 +1686,7 @@ pub fn commit( ) -> Result<()> { // get the files to commit let statuses = get_status_by_branch(gb_repository, project_repository) - .expect("failed to get status by branch"); + .context("failed to get status by branch")?; for (mut branch, files) in statuses { if branch.id == branch_id {