diff --git a/crates/gitbutler-core/src/virtual_branches/base.rs b/crates/gitbutler-core/src/virtual_branches/base.rs index 2e3eda774..d8375012a 100644 --- a/crates/gitbutler-core/src/virtual_branches/base.rs +++ b/crates/gitbutler-core/src/virtual_branches/base.rs @@ -336,7 +336,7 @@ fn _print_tree(repo: &git2::Repository, tree: &git2::Tree) -> Result<()> { pub fn update_base_branch( project_repository: &project_repository::Repository, user: Option<&users::User>, -) -> anyhow::Result<()> { +) -> anyhow::Result> { if project_repository.is_resolving() { anyhow::bail!(errors::UpdateBaseBranchError::Conflict( errors::ProjectConflict { @@ -356,8 +356,10 @@ pub fn update_base_branch( .peel_to_commit() .context(format!("failed to peel branch {} to commit", target.branch))?; + let mut unapplied_branches: Vec = Vec::new(); + if new_target_commit.id() == target.sha.into() { - return Ok(()); + return Ok(unapplied_branches); } let new_target_tree = new_target_commit @@ -433,6 +435,7 @@ pub fn update_base_branch( // branch tree conflicts with new target, unapply branch for now. we'll handle it later, when user applies it back. branch.applied = false; vb_state.set_branch(branch.clone())?; + unapplied_branches.push(branch.clone()); return Ok(Some(branch)); } @@ -569,7 +572,7 @@ pub fn update_base_branch( // Rewriting the integration commit is necessary after changing target sha. super::integration::update_gitbutler_integration(&vb_state, project_repository)?; - Ok(()) + Ok(unapplied_branches) } pub fn target_to_base_branch( diff --git a/crates/gitbutler-core/src/virtual_branches/controller.rs b/crates/gitbutler-core/src/virtual_branches/controller.rs index f7c3ac33c..fcf5bd78f 100644 --- a/crates/gitbutler-core/src/virtual_branches/controller.rs +++ b/crates/gitbutler-core/src/virtual_branches/controller.rs @@ -9,8 +9,8 @@ use tokio::{sync::Semaphore, task::JoinHandle}; use super::{ branch::{BranchId, BranchOwnershipClaims}, - errors::{self}, - target, target_to_base_branch, BaseBranch, RemoteBranchFile, VirtualBranchesHandle, + errors, target, target_to_base_branch, BaseBranch, Branch, RemoteBranchFile, + VirtualBranchesHandle, }; use crate::{ git, project_repository, @@ -164,7 +164,7 @@ impl Controller { .await } - pub async fn update_base_branch(&self, project_id: ProjectId) -> Result<(), Error> { + pub async fn update_base_branch(&self, project_id: ProjectId) -> Result, Error> { self.inner(project_id) .await .update_base_branch(project_id) @@ -587,7 +587,7 @@ impl ControllerInner { }) } - pub async fn update_base_branch(&self, project_id: ProjectId) -> Result<(), Error> { + pub async fn update_base_branch(&self, project_id: ProjectId) -> Result, Error> { let _permit = self.semaphore.acquire().await; self.with_verify_branch(project_id, |project_repository, user| { diff --git a/crates/gitbutler-tauri/src/virtual_branches.rs b/crates/gitbutler-tauri/src/virtual_branches.rs index 190e62539..9813f7041 100644 --- a/crates/gitbutler-tauri/src/virtual_branches.rs +++ b/crates/gitbutler-tauri/src/virtual_branches.rs @@ -150,13 +150,16 @@ pub mod commands { #[tauri::command(async)] #[instrument(skip(handle), err(Debug))] - pub async fn update_base_branch(handle: AppHandle, project_id: ProjectId) -> Result<(), Error> { - handle + pub async fn update_base_branch( + handle: AppHandle, + project_id: ProjectId, + ) -> Result, Error> { + let unapplied_branches = handle .state::() .update_base_branch(project_id) .await?; emit_vbranches(&handle, project_id).await; - Ok(()) + Ok(unapplied_branches) } #[tauri::command(async)] diff --git a/crates/gitbutler-watcher/src/debouncer/mod.rs b/crates/gitbutler-watcher/src/debouncer/mod.rs index 5a8b958ed..a40a693f0 100644 --- a/crates/gitbutler-watcher/src/debouncer/mod.rs +++ b/crates/gitbutler-watcher/src/debouncer/mod.rs @@ -780,7 +780,7 @@ mod tests { for (delay, events) in expected_events { MockClock::set_time(backup_time); - state.queues = backup_queues.clone(); + state.queues.clone_from(&backup_queues); match delay.as_str() { "none" => {} diff --git a/crates/gitbutler-watcher/src/debouncer/testing/mod.rs b/crates/gitbutler-watcher/src/debouncer/testing/mod.rs index b82c32f9a..90085acef 100644 --- a/crates/gitbutler-watcher/src/debouncer/testing/mod.rs +++ b/crates/gitbutler-watcher/src/debouncer/testing/mod.rs @@ -192,7 +192,7 @@ mod utils { fn add_path(&mut self, path: &Path) { for (p, file_id) in &self.file_system { if p.starts_with(path) { - self.paths.insert(p.clone(), file_id.clone()); + self.paths.insert(p.clone(), *file_id); } } } @@ -202,7 +202,7 @@ mod utils { } fn rescan(&mut self) { - self.add_path(&Path::new("/")); + self.add_path(Path::new("/")); } } }