rm gb_repository from apply_branch

This commit is contained in:
Kiril Videlov 2024-04-19 22:44:42 +02:00
parent 21fdfb4272
commit 45c1342a53
No known key found for this signature in database
3 changed files with 7 additions and 20 deletions

View File

@ -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)
})
}

View File

@ -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

View File

@ -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)?);