mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-05 17:15:19 +03:00
Merge pull request #4319 from gitbutlerapp/remove-virtual-branch-controller
remove virtual branch controller
This commit is contained in:
commit
7f7928d40c
@ -128,8 +128,6 @@ fn main() {
|
||||
let git_credentials_controller = Helper::default();
|
||||
app_handle.manage(git_credentials_controller.clone());
|
||||
|
||||
app_handle.manage(gitbutler_virtual::controller::Controller::default());
|
||||
|
||||
let app = app::App::new(
|
||||
projects_controller,
|
||||
);
|
||||
|
@ -11,7 +11,7 @@ pub mod commands {
|
||||
use gitbutler_virtual::base::BaseBranch;
|
||||
use gitbutler_virtual::files::RemoteBranchFile;
|
||||
use gitbutler_virtual::remote::{RemoteBranch, RemoteBranchData};
|
||||
use gitbutler_virtual::{Controller, NameConflitResolution, VirtualBranches};
|
||||
use gitbutler_virtual::{NameConflitResolution, VirtualBranchActions, VirtualBranches};
|
||||
use tauri::{AppHandle, Manager};
|
||||
use tracing::instrument;
|
||||
|
||||
@ -28,8 +28,7 @@ pub mod commands {
|
||||
run_hooks: bool,
|
||||
) -> Result<String, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
let oid = VirtualBranchActions::default()
|
||||
.create_commit(&project, branch, message, ownership.as_ref(), run_hooks)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -43,8 +42,7 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
) -> Result<VirtualBranches, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let (branches, skipped_files) = handle
|
||||
.state::<Controller>()
|
||||
let (branches, skipped_files) = VirtualBranchActions::default()
|
||||
.list_virtual_branches(&project)
|
||||
.await?;
|
||||
|
||||
@ -62,8 +60,7 @@ pub mod commands {
|
||||
branch: BranchCreateRequest,
|
||||
) -> Result<BranchId, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_id = handle
|
||||
.state::<Controller>()
|
||||
let branch_id = VirtualBranchActions::default()
|
||||
.create_virtual_branch(&project, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -78,8 +75,7 @@ pub mod commands {
|
||||
branch: Refname,
|
||||
) -> Result<BranchId, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_id = handle
|
||||
.state::<Controller>()
|
||||
let branch_id = VirtualBranchActions::default()
|
||||
.create_virtual_branch_from_branch(&project, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -94,8 +90,7 @@ pub mod commands {
|
||||
branch: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.integrate_upstream_commits(&project, branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -109,8 +104,7 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
) -> Result<Option<BaseBranch>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
if let Ok(base_branch) = handle
|
||||
.state::<Controller>()
|
||||
if let Ok(base_branch) = VirtualBranchActions::default()
|
||||
.get_base_branch_data(&project)
|
||||
.await
|
||||
{
|
||||
@ -132,15 +126,14 @@ pub mod commands {
|
||||
let branch_name = format!("refs/remotes/{}", branch)
|
||||
.parse()
|
||||
.context("Invalid branch name")?;
|
||||
let base_branch = handle
|
||||
.state::<Controller>()
|
||||
let base_branch = VirtualBranchActions::default()
|
||||
.set_base_branch(&project, &branch_name)
|
||||
.await?;
|
||||
|
||||
// if they also sent a different push remote, set that too
|
||||
if let Some(push_remote) = push_remote {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.state::<VirtualBranchActions>()
|
||||
.set_target_push_remote(&project, push_remote)
|
||||
.await?;
|
||||
}
|
||||
@ -155,8 +148,7 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<ReferenceName>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let unapplied_branches = handle
|
||||
.state::<Controller>()
|
||||
let unapplied_branches = VirtualBranchActions::default()
|
||||
.update_base_branch(&project)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -171,8 +163,7 @@ pub mod commands {
|
||||
branch: BranchUpdateRequest,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.update_virtual_branch(&project, branch)
|
||||
.await?;
|
||||
|
||||
@ -188,8 +179,7 @@ pub mod commands {
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.delete_virtual_branch(&project, branch_id)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -205,8 +195,7 @@ pub mod commands {
|
||||
name_conflict_resolution: NameConflitResolution,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.convert_to_real_branch(&project, branch, name_conflict_resolution)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -221,8 +210,7 @@ pub mod commands {
|
||||
ownership: BranchOwnershipClaims,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.unapply_ownership(&project, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -242,8 +230,7 @@ pub mod commands {
|
||||
.split('\n')
|
||||
.map(std::string::ToString::to_string)
|
||||
.collect::<Vec<String>>();
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.reset_files(&project, &files)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -259,8 +246,7 @@ pub mod commands {
|
||||
with_force: bool,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.push_virtual_branch(&project, branch_id, with_force, Some(Some(branch_id)))
|
||||
.await
|
||||
.map_err(|err| err.context(Code::Unknown))?;
|
||||
@ -276,8 +262,7 @@ pub mod commands {
|
||||
branch: RemoteRefname,
|
||||
) -> Result<bool, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
Ok(handle
|
||||
.state::<Controller>()
|
||||
Ok(VirtualBranchActions::default()
|
||||
.can_apply_remote_branch(&project, &branch)
|
||||
.await?)
|
||||
}
|
||||
@ -291,8 +276,7 @@ pub mod commands {
|
||||
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.list_remote_commit_files(&project, commit_oid)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
@ -308,8 +292,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let target_commit_oid = git2::Oid::from_str(&target_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.reset_virtual_branch(&project, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -327,8 +310,7 @@ pub mod commands {
|
||||
) -> Result<String, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
let oid = VirtualBranchActions::default()
|
||||
.amend(&project, branch_id, commit_oid, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -348,8 +330,7 @@ pub mod commands {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let from_commit_oid = git2::Oid::from_str(&from_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
let to_commit_oid = git2::Oid::from_str(&to_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
let oid = VirtualBranchActions::default()
|
||||
.move_commit_file(
|
||||
&project,
|
||||
branch_id,
|
||||
@ -372,8 +353,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.undo_commit(&project, branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -391,8 +371,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.insert_blank_commit(&project, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -410,8 +389,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.reorder_commit(&project, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -425,8 +403,7 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<RemoteBranch>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branches = handle
|
||||
.state::<Controller>()
|
||||
let branches = VirtualBranchActions::default()
|
||||
.list_remote_branches(project)
|
||||
.await?;
|
||||
Ok(branches)
|
||||
@ -440,8 +417,7 @@ pub mod commands {
|
||||
refname: Refname,
|
||||
) -> Result<RemoteBranchData, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_data = handle
|
||||
.state::<Controller>()
|
||||
let branch_data = VirtualBranchActions::default()
|
||||
.get_remote_branch_data(&project, &refname)
|
||||
.await?;
|
||||
Ok(branch_data)
|
||||
@ -457,8 +433,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let target_commit_oid = git2::Oid::from_str(&target_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.squash(&project, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -475,8 +450,7 @@ pub mod commands {
|
||||
let projects = handle.state::<projects::Controller>();
|
||||
let project = projects.get(project_id)?;
|
||||
|
||||
let project_data_last_fetched = handle
|
||||
.state::<Controller>()
|
||||
let project_data_last_fetched = VirtualBranchActions::default()
|
||||
.fetch_from_remotes(
|
||||
&project,
|
||||
Some(action.unwrap_or_else(|| "unknown".to_string())),
|
||||
@ -495,8 +469,7 @@ pub mod commands {
|
||||
.await
|
||||
.context("failed to update project with last fetched timestamp")?;
|
||||
|
||||
let base_branch = handle
|
||||
.state::<Controller>()
|
||||
let base_branch = VirtualBranchActions::default()
|
||||
.get_base_branch_data(&project)
|
||||
.await?;
|
||||
Ok(base_branch)
|
||||
@ -512,8 +485,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.move_commit(&project, target_branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -531,8 +503,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
VirtualBranchActions::default()
|
||||
.update_commit_message(&project, branch_id, commit_oid, message)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
|
@ -77,7 +77,7 @@ pub struct Watchers {
|
||||
fn handler_from_app(app: &AppHandle) -> anyhow::Result<gitbutler_watcher::Handler> {
|
||||
let projects = app.state::<projects::Controller>().inner().clone();
|
||||
let users = app.state::<users::Controller>().inner().clone();
|
||||
let vbranches = app.state::<gitbutler_virtual::Controller>().inner().clone();
|
||||
let vbranches = gitbutler_virtual::VirtualBranchActions::default();
|
||||
|
||||
Ok(gitbutler_watcher::Handler::new(
|
||||
projects,
|
||||
|
@ -15,9 +15,7 @@ use gitbutler_project::{FetchResult, Project};
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::{credentials::Helper, RepoActions, RepositoryExt};
|
||||
use gitbutler_tagged_string::ReferenceName;
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use tokio::sync::Semaphore;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{
|
||||
base::{
|
||||
@ -33,20 +31,10 @@ use super::r#virtual as branch;
|
||||
use crate::files::RemoteBranchFile;
|
||||
use gitbutler_branch::target;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Controller {
|
||||
semaphore: Arc<Semaphore>,
|
||||
}
|
||||
#[derive(Clone, Default)]
|
||||
pub struct VirtualBranchActions {}
|
||||
|
||||
impl Default for Controller {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
semaphore: Arc::new(Semaphore::new(1)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Controller {
|
||||
impl VirtualBranchActions {
|
||||
pub async fn create_commit(
|
||||
&self,
|
||||
project: &Project,
|
||||
@ -55,7 +43,6 @@ impl Controller {
|
||||
ownership: Option<&BranchOwnershipClaims>,
|
||||
run_hooks: bool,
|
||||
) -> Result<git2::Oid> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let result = branch::commit(
|
||||
@ -90,8 +77,6 @@ impl Controller {
|
||||
&self,
|
||||
project: &Project,
|
||||
) -> Result<(Vec<branch::VirtualBranch>, Vec<diff::FileDiff>)> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
branch::list_virtual_branches(&project_repository).map_err(Into::into)
|
||||
}
|
||||
@ -101,8 +86,6 @@ impl Controller {
|
||||
project: &Project,
|
||||
create: &BranchCreateRequest,
|
||||
) -> Result<BranchId> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let branch_manager = project_repository.branch_manager();
|
||||
let branch_id = branch_manager.create_virtual_branch(create)?.id;
|
||||
@ -146,8 +129,6 @@ impl Controller {
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -156,8 +137,6 @@ impl Controller {
|
||||
}
|
||||
|
||||
pub async fn update_base_branch(&self, project: &Project) -> Result<Vec<ReferenceName>> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -170,8 +149,6 @@ impl Controller {
|
||||
project: &Project,
|
||||
branch_update: BranchUpdateRequest,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let old_branch = project_repository
|
||||
@ -195,8 +172,6 @@ impl Controller {
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let branch_manager = project_repository.branch_manager();
|
||||
branch_manager.delete_branch(branch_id)
|
||||
@ -207,8 +182,6 @@ impl Controller {
|
||||
project: &Project,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -217,8 +190,6 @@ impl Controller {
|
||||
}
|
||||
|
||||
pub async fn reset_files(&self, project: &Project, files: &Vec<String>) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -233,8 +204,6 @@ impl Controller {
|
||||
commit_oid: git2::Oid,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<git2::Oid> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -250,8 +219,6 @@ impl Controller {
|
||||
to_commit_oid: git2::Oid,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<git2::Oid> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -272,8 +239,6 @@ impl Controller {
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let result: Result<()> =
|
||||
@ -295,8 +260,6 @@ impl Controller {
|
||||
commit_oid: git2::Oid,
|
||||
offset: i32,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -312,8 +275,6 @@ impl Controller {
|
||||
commit_oid: git2::Oid,
|
||||
offset: i32,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -328,8 +289,6 @@ impl Controller {
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -343,8 +302,6 @@ impl Controller {
|
||||
branch_id: BranchId,
|
||||
name_conflict_resolution: branch::NameConflitResolution,
|
||||
) -> Result<ReferenceName> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let branch_manager = project_repository.branch_manager();
|
||||
@ -366,7 +323,6 @@ impl Controller {
|
||||
with_force: bool,
|
||||
askpass: Option<Option<BranchId>>,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
let helper = Helper::default();
|
||||
let project_repository = open_with_verify(project)?;
|
||||
branch::push(&project_repository, branch_id, with_force, &helper, askpass)
|
||||
@ -392,8 +348,6 @@ impl Controller {
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -408,7 +362,6 @@ impl Controller {
|
||||
commit_oid: git2::Oid,
|
||||
message: &str,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -466,8 +419,6 @@ impl Controller {
|
||||
target_branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
@ -480,20 +431,12 @@ impl Controller {
|
||||
project: &Project,
|
||||
branch: &Refname,
|
||||
) -> Result<BranchId> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
let project_repository = open_with_verify(project)?;
|
||||
let branch_manager = project_repository.branch_manager();
|
||||
branch_manager
|
||||
.create_virtual_branch_from_branch(branch)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
async fn permit(&self, ignore: bool) {
|
||||
if !ignore {
|
||||
let _ = self.semaphore.acquire().await.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn open_with_verify(project: &Project) -> Result<ProjectRepository> {
|
@ -1,6 +1,6 @@
|
||||
//! GitButler internal library containing functionaliry related to branches, i.e. the virtual branches implementation
|
||||
pub mod controller;
|
||||
pub use controller::Controller;
|
||||
pub mod actions;
|
||||
pub use actions::VirtualBranchActions;
|
||||
|
||||
pub mod r#virtual;
|
||||
pub use r#virtual::*;
|
||||
|
@ -134,7 +134,7 @@ fn commit_and_push_initial(repository: &TestProject) {
|
||||
}
|
||||
|
||||
async fn get_virtual_branch(
|
||||
controller: &Controller,
|
||||
controller: &VirtualBranchActions,
|
||||
project: &Project,
|
||||
branch_id: Id<Branch>,
|
||||
) -> VirtualBranch {
|
||||
|
@ -7,7 +7,7 @@ async fn twice() {
|
||||
|
||||
let test_project = TestProject::default();
|
||||
|
||||
let controller = Controller::default();
|
||||
let controller = VirtualBranchActions {};
|
||||
|
||||
{
|
||||
let project = projects
|
||||
|
@ -5,7 +5,7 @@ use gitbutler_branch::branch;
|
||||
use gitbutler_error::error::Marker;
|
||||
use gitbutler_project::{self as projects, Project, ProjectId};
|
||||
use gitbutler_reference::Refname;
|
||||
use gitbutler_virtual::Controller;
|
||||
use gitbutler_virtual::VirtualBranchActions;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use gitbutler_testsupport::{paths, TestProject, VAR_NO_CLEANUP};
|
||||
@ -15,7 +15,7 @@ struct Test {
|
||||
project_id: ProjectId,
|
||||
project: Project,
|
||||
projects: projects::Controller,
|
||||
controller: Controller,
|
||||
controller: VirtualBranchActions,
|
||||
data_dir: Option<TempDir>,
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ impl Default for Test {
|
||||
Self {
|
||||
repository: test_project,
|
||||
project_id: project.id,
|
||||
controller: Controller::default(),
|
||||
controller: VirtualBranchActions {},
|
||||
projects,
|
||||
project,
|
||||
data_dir: Some(data_dir),
|
||||
|
@ -30,7 +30,7 @@ pub struct Handler {
|
||||
// need extra protection.
|
||||
projects: projects::Controller,
|
||||
users: users::Controller,
|
||||
vbranch_controller: gitbutler_virtual::Controller,
|
||||
vbranch_controller: gitbutler_virtual::VirtualBranchActions,
|
||||
|
||||
/// A function to send events - decoupled from app-handle for testing purposes.
|
||||
#[allow(clippy::type_complexity)]
|
||||
@ -43,7 +43,7 @@ impl Handler {
|
||||
pub fn new(
|
||||
projects: projects::Controller,
|
||||
users: users::Controller,
|
||||
vbranch_controller: gitbutler_virtual::Controller,
|
||||
vbranch_controller: gitbutler_virtual::VirtualBranchActions,
|
||||
send_event: impl Fn(Change) -> Result<()> + Send + Sync + 'static,
|
||||
) -> Self {
|
||||
Handler {
|
||||
|
Loading…
Reference in New Issue
Block a user