From 45c1342a53577df6b60607a51cb201d15d70c933 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Fri, 19 Apr 2024 22:44:42 +0200 Subject: [PATCH] rm gb_repository from apply_branch --- .../src/virtual_branches/controller.rs | 12 +++--------- .../gitbutler-core/src/virtual_branches/virtual.rs | 9 +-------- crates/gitbutler-core/tests/virtual_branches/mod.rs | 6 +++--- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/crates/gitbutler-core/src/virtual_branches/controller.rs b/crates/gitbutler-core/src/virtual_branches/controller.rs index 2eb0b1359..59b78aef3 100644 --- a/crates/gitbutler-core/src/virtual_branches/controller.rs +++ b/crates/gitbutler-core/src/virtual_branches/controller.rs @@ -699,7 +699,7 @@ impl ControllerInner { ) -> Result<(), Error> { let _permit = self.semaphore.acquire().await; - self.with_verify_branch(project_id, |gb_repository, project_repository, user| { + self.with_verify_branch(project_id, |_, project_repository, user| { let signing_key = project_repository .config() .sign_commits() @@ -711,14 +711,8 @@ impl ControllerInner { }) .transpose()?; - super::apply_branch( - gb_repository, - project_repository, - branch_id, - signing_key.as_ref(), - user, - ) - .map_err(Into::into) + super::apply_branch(project_repository, branch_id, signing_key.as_ref(), user) + .map_err(Into::into) }) } diff --git a/crates/gitbutler-core/src/virtual_branches/virtual.rs b/crates/gitbutler-core/src/virtual_branches/virtual.rs index 7e12c9e7c..162af1c93 100644 --- a/crates/gitbutler-core/src/virtual_branches/virtual.rs +++ b/crates/gitbutler-core/src/virtual_branches/virtual.rs @@ -183,7 +183,6 @@ fn get_default_target( } pub fn apply_branch( - gb_repository: &gb_repository::Repository, project_repository: &project_repository::Repository, branch_id: &BranchId, signing_key: Option<&keys::PrivateKey>, @@ -3644,13 +3643,7 @@ pub fn create_virtual_branch_from_branch( project_repository.add_branch_reference(&branch)?; - match apply_branch( - gb_repository, - project_repository, - &branch.id, - signing_key, - user, - ) { + match apply_branch(project_repository, &branch.id, signing_key, user) { Ok(()) => Ok(branch.id), Err(errors::ApplyBranchError::BranchConflicts(_)) => { // if branch conflicts with the workspace, it's ok. keep it unapplied diff --git a/crates/gitbutler-core/tests/virtual_branches/mod.rs b/crates/gitbutler-core/tests/virtual_branches/mod.rs index d2625b37b..237a54699 100644 --- a/crates/gitbutler-core/tests/virtual_branches/mod.rs +++ b/crates/gitbutler-core/tests/virtual_branches/mod.rs @@ -1168,7 +1168,7 @@ fn unapply_branch() -> Result<()> { assert_eq!(branch.files.len(), 1); assert!(!branch.active); - apply_branch(gb_repository, project_repository, &branch1_id, None, None)?; + apply_branch(project_repository, &branch1_id, None, None)?; let contents = std::fs::read(Path::new(&project.path).join(file_path))?; assert_eq!( "line1\nline2\nline3\nline4\nbranch1\n", @@ -1242,11 +1242,11 @@ fn apply_unapply_added_deleted_files() -> Result<()> { // check that file3 is gone assert!(!Path::new(&project.path).join(file_path3).exists()); - apply_branch(gb_repository, project_repository, &branch2_id, None, None)?; + apply_branch(project_repository, &branch2_id, None, None)?; // check that file2 is gone assert!(!Path::new(&project.path).join(file_path2).exists()); - apply_branch(gb_repository, project_repository, &branch3_id, None, None)?; + apply_branch(project_repository, &branch3_id, None, None)?; // check that file3 is back let contents = std::fs::read(Path::new(&project.path).join(file_path3))?; assert_eq!("file3\n", String::from_utf8(contents)?);