From 4125dcef3baf2978cf363460487a3cdaed3a321b Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Sat, 20 Jul 2024 21:44:20 +0200 Subject: [PATCH] get remove vbranches list as function parameter --- .../src/branch_manager/branch_removal.rs | 14 ++----- .../gitbutler-branch-actions/src/virtual.rs | 40 +++++-------------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs b/crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs index 020915ffb..42bd653cc 100644 --- a/crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs +++ b/crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs @@ -74,17 +74,9 @@ impl BranchManager<'_> { let target_commit = repo.target_commit()?; let base_tree = target_commit.tree().context("failed to get target tree")?; - let virtual_branches = vb_state - .list_branches_in_workspace() - .context("failed to read virtual branches")?; - - let (applied_statuses, _, _) = get_applied_status( - self.project_repository, - &integration_commit.id(), - virtual_branches, - None, - ) - .context("failed to get status by branch")?; + let (applied_statuses, _, _) = + get_applied_status(self.project_repository, &integration_commit.id(), None) + .context("failed to get status by branch")?; // go through the other applied branches and merge them into the final tree // then check that out into the working directory diff --git a/crates/gitbutler-branch-actions/src/virtual.rs b/crates/gitbutler-branch-actions/src/virtual.rs index 9c0d0318d..fb7613dbc 100644 --- a/crates/gitbutler-branch-actions/src/virtual.rs +++ b/crates/gitbutler-branch-actions/src/virtual.rs @@ -231,19 +231,11 @@ pub fn unapply_ownership( let vb_state = project_repository.project().virtual_branches(); - let virtual_branches = vb_state - .list_branches_in_workspace() - .context("failed to read virtual branches")?; - let integration_commit_id = get_workspace_head(&vb_state, project_repository)?; - let (applied_statuses, _, _) = get_applied_status( - project_repository, - &integration_commit_id, - virtual_branches, - None, - ) - .context("failed to get status by branch")?; + let (applied_statuses, _, _) = + get_applied_status(project_repository, &integration_commit_id, None) + .context("failed to get status by branch")?; let hunks_to_unapply = applied_statuses .iter() @@ -1085,15 +1077,10 @@ pub fn get_status_by_branch( let default_target = vb_state.get_default_target()?; - let virtual_branches = vb_state - .list_branches_in_workspace() - .context("failed to read virtual branches")?; - let (applied_status, skipped_files, locks) = get_applied_status( project_repository, // TODO: Keep this optional or update lots of tests? integration_commit.unwrap_or(&default_target.sha), - virtual_branches, perm, )?; @@ -1195,13 +1182,16 @@ fn new_compute_locks( pub(crate) fn get_applied_status( project_repository: &ProjectRepository, integration_commit: &git2::Oid, - mut virtual_branches: Vec, perm: Option<&mut WorktreeWritePermission>, ) -> Result<( AppliedStatuses, Vec, HashMap>, )> { + let mut virtual_branches = project_repository + .project() + .virtual_branches() + .list_branches_in_workspace()?; let base_file_diffs = gitbutler_diff::workdir(project_repository.repo(), &integration_commit.to_owned()) .context("failed to diff workdir")?; @@ -2253,12 +2243,8 @@ pub(crate) fn amend( let integration_commit_id = get_workspace_head(&vb_state, project_repository)?; - let (mut applied_statuses, _, _) = get_applied_status( - project_repository, - &integration_commit_id, - virtual_branches, - None, - )?; + let (mut applied_statuses, _, _) = + get_applied_status(project_repository, &integration_commit_id, None)?; let (ref mut target_branch, target_status) = applied_statuses .iter_mut() @@ -2740,12 +2726,8 @@ pub(crate) fn move_commit( let integration_commit_id = get_workspace_head(&vb_state, project_repository)?; - let (mut applied_statuses, _, _) = get_applied_status( - project_repository, - &integration_commit_id, - applied_branches, - None, - )?; + let (mut applied_statuses, _, _) = + get_applied_status(project_repository, &integration_commit_id, None)?; let (ref mut source_branch, source_status) = applied_statuses .iter_mut()