mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-28 03:55:02 +03:00
adapt to changes in gitbutler-branch-actions
This commit is contained in:
parent
5e408f6b2d
commit
4805f6e7e7
@ -3,10 +3,10 @@ pub mod commands {
|
||||
use anyhow::{anyhow, Context};
|
||||
use gitbutler_branch::branch::{BranchCreateRequest, BranchId, BranchUpdateRequest};
|
||||
use gitbutler_branch::ownership::BranchOwnershipClaims;
|
||||
use gitbutler_branch_actions::base::BaseBranch;
|
||||
use gitbutler_branch_actions::files::RemoteBranchFile;
|
||||
use gitbutler_branch_actions::remote::{RemoteBranch, RemoteBranchData};
|
||||
use gitbutler_branch_actions::{NameConflitResolution, VirtualBranchActions, VirtualBranches};
|
||||
use gitbutler_branch_actions::BaseBranch;
|
||||
use gitbutler_branch_actions::RemoteBranchFile;
|
||||
use gitbutler_branch_actions::{NameConflictResolution, VirtualBranchActions, VirtualBranches};
|
||||
use gitbutler_branch_actions::{RemoteBranch, RemoteBranchData};
|
||||
use gitbutler_error::error::Code;
|
||||
use gitbutler_project as projects;
|
||||
use gitbutler_project::ProjectId;
|
||||
@ -28,7 +28,7 @@ pub mod commands {
|
||||
run_hooks: bool,
|
||||
) -> Result<String, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let oid = VirtualBranchActions::default()
|
||||
let oid = VirtualBranchActions
|
||||
.create_commit(&project, branch, message, ownership.as_ref(), run_hooks)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -42,9 +42,8 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
) -> Result<VirtualBranches, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let (branches, skipped_files) = VirtualBranchActions::default()
|
||||
.list_virtual_branches(&project)
|
||||
.await?;
|
||||
let (branches, skipped_files) =
|
||||
VirtualBranchActions.list_virtual_branches(&project).await?;
|
||||
|
||||
Ok(VirtualBranches {
|
||||
branches,
|
||||
@ -60,7 +59,7 @@ pub mod commands {
|
||||
branch: BranchCreateRequest,
|
||||
) -> Result<BranchId, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_id = VirtualBranchActions::default()
|
||||
let branch_id = VirtualBranchActions
|
||||
.create_virtual_branch(&project, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -75,7 +74,7 @@ pub mod commands {
|
||||
branch: Refname,
|
||||
) -> Result<BranchId, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_id = VirtualBranchActions::default()
|
||||
let branch_id = VirtualBranchActions
|
||||
.create_virtual_branch_from_branch(&project, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -90,7 +89,7 @@ pub mod commands {
|
||||
branch: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.integrate_upstream_commits(&project, branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -104,10 +103,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) = VirtualBranchActions::default()
|
||||
.get_base_branch_data(&project)
|
||||
.await
|
||||
{
|
||||
if let Ok(base_branch) = VirtualBranchActions.get_base_branch_data(&project).await {
|
||||
Ok(Some(base_branch))
|
||||
} else {
|
||||
Ok(None)
|
||||
@ -126,13 +122,13 @@ pub mod commands {
|
||||
let branch_name = format!("refs/remotes/{}", branch)
|
||||
.parse()
|
||||
.context("Invalid branch name")?;
|
||||
let base_branch = VirtualBranchActions::default()
|
||||
let base_branch = VirtualBranchActions
|
||||
.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 {
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.set_target_push_remote(&project, push_remote)
|
||||
.await?;
|
||||
}
|
||||
@ -147,9 +143,7 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<ReferenceName>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let unapplied_branches = VirtualBranchActions::default()
|
||||
.update_base_branch(&project)
|
||||
.await?;
|
||||
let unapplied_branches = VirtualBranchActions.update_base_branch(&project).await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(unapplied_branches)
|
||||
}
|
||||
@ -162,7 +156,7 @@ pub mod commands {
|
||||
branch: BranchUpdateRequest,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.update_virtual_branch(&project, branch)
|
||||
.await?;
|
||||
|
||||
@ -178,7 +172,7 @@ pub mod commands {
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.delete_virtual_branch(&project, branch_id)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -191,10 +185,10 @@ pub mod commands {
|
||||
handle: AppHandle,
|
||||
project_id: ProjectId,
|
||||
branch: BranchId,
|
||||
name_conflict_resolution: NameConflitResolution,
|
||||
name_conflict_resolution: NameConflictResolution,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.convert_to_real_branch(&project, branch, name_conflict_resolution)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -209,7 +203,7 @@ pub mod commands {
|
||||
ownership: BranchOwnershipClaims,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.unapply_ownership(&project, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -229,9 +223,7 @@ pub mod commands {
|
||||
.split('\n')
|
||||
.map(std::string::ToString::to_string)
|
||||
.collect::<Vec<String>>();
|
||||
VirtualBranchActions::default()
|
||||
.reset_files(&project, &files)
|
||||
.await?;
|
||||
VirtualBranchActions.reset_files(&project, &files).await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
@ -245,7 +237,7 @@ pub mod commands {
|
||||
with_force: bool,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.push_virtual_branch(&project, branch_id, with_force, Some(Some(branch_id)))
|
||||
.await
|
||||
.map_err(|err| err.context(Code::Unknown))?;
|
||||
@ -261,7 +253,7 @@ pub mod commands {
|
||||
branch: RemoteRefname,
|
||||
) -> Result<bool, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
Ok(VirtualBranchActions::default()
|
||||
Ok(VirtualBranchActions
|
||||
.can_apply_remote_branch(&project, &branch)
|
||||
.await?)
|
||||
}
|
||||
@ -275,7 +267,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.list_remote_commit_files(&project, commit_oid)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
@ -291,7 +283,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.reset_virtual_branch(&project, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -309,7 +301,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 = VirtualBranchActions::default()
|
||||
let oid = VirtualBranchActions
|
||||
.amend(&project, branch_id, commit_oid, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -329,7 +321,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 = VirtualBranchActions::default()
|
||||
let oid = VirtualBranchActions
|
||||
.move_commit_file(
|
||||
&project,
|
||||
branch_id,
|
||||
@ -352,7 +344,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.undo_commit(&project, branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -370,7 +362,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.insert_blank_commit(&project, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -388,7 +380,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.reorder_commit(&project, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -402,9 +394,7 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<RemoteBranch>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branches = VirtualBranchActions::default()
|
||||
.list_remote_branches(project)
|
||||
.await?;
|
||||
let branches = VirtualBranchActions.list_remote_branches(project).await?;
|
||||
Ok(branches)
|
||||
}
|
||||
|
||||
@ -416,7 +406,7 @@ pub mod commands {
|
||||
refname: Refname,
|
||||
) -> Result<RemoteBranchData, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_data = VirtualBranchActions::default()
|
||||
let branch_data = VirtualBranchActions
|
||||
.get_remote_branch_data(&project, &refname)
|
||||
.await?;
|
||||
Ok(branch_data)
|
||||
@ -432,7 +422,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.squash(&project, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -449,7 +439,7 @@ pub mod commands {
|
||||
let projects = handle.state::<projects::Controller>();
|
||||
let project = projects.get(project_id)?;
|
||||
|
||||
let project_data_last_fetched = VirtualBranchActions::default()
|
||||
let project_data_last_fetched = VirtualBranchActions
|
||||
.fetch_from_remotes(
|
||||
&project,
|
||||
Some(action.unwrap_or_else(|| "unknown".to_string())),
|
||||
@ -468,9 +458,7 @@ pub mod commands {
|
||||
.await
|
||||
.context("failed to update project with last fetched timestamp")?;
|
||||
|
||||
let base_branch = VirtualBranchActions::default()
|
||||
.get_base_branch_data(&project)
|
||||
.await?;
|
||||
let base_branch = VirtualBranchActions.get_base_branch_data(&project).await?;
|
||||
Ok(base_branch)
|
||||
}
|
||||
|
||||
@ -484,7 +472,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.move_commit(&project, target_branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -502,7 +490,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))?;
|
||||
VirtualBranchActions::default()
|
||||
VirtualBranchActions
|
||||
.update_commit_message(&project, branch_id, commit_oid, message)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
|
@ -104,7 +104,7 @@ pub(super) mod state {
|
||||
fn handler_from_app(app: &AppHandle) -> Result<gitbutler_watcher::Handler> {
|
||||
let projects = app.state::<projects::Controller>().inner().clone();
|
||||
let users = app.state::<users::Controller>().inner().clone();
|
||||
let vbranches = gitbutler_branch_actions::VirtualBranchActions::default();
|
||||
let vbranches = gitbutler_branch_actions::VirtualBranchActions;
|
||||
|
||||
Ok(gitbutler_watcher::Handler::new(
|
||||
projects,
|
||||
|
@ -42,11 +42,8 @@ pub mod virtual_branches {
|
||||
})
|
||||
.expect("failed to write target");
|
||||
|
||||
gitbutler_branch_actions::integration::update_gitbutler_integration(
|
||||
&vb_state,
|
||||
project_repository,
|
||||
)
|
||||
.expect("failed to update integration");
|
||||
gitbutler_branch_actions::update_gitbutler_integration(&vb_state, project_repository)
|
||||
.expect("failed to update integration");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user