rename gitbutler-virtual to gitbutler-branch-actions

This is to establish a patter of which crates represent a higher level logic
This commit is contained in:
Kiril Videlov 2024-07-10 14:49:48 +02:00
parent 1c78ec7725
commit c8658b9a23
No known key found for this signature in database
GPG Key ID: A4C733025427C471
49 changed files with 79 additions and 76 deletions

94
Cargo.lock generated
View File

@ -1979,6 +1979,50 @@ dependencies = [
"tracing",
]
[[package]]
name = "gitbutler-branch-actions"
version = "0.0.0"
dependencies = [
"anyhow",
"bstr",
"diffy",
"futures",
"git2",
"git2-hooks",
"gitbutler-branch",
"gitbutler-branchstate",
"gitbutler-command-context",
"gitbutler-commit",
"gitbutler-error",
"gitbutler-git",
"gitbutler-id",
"gitbutler-oplog",
"gitbutler-project",
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-serde",
"gitbutler-tagged-string",
"gitbutler-testsupport",
"gitbutler-time",
"gitbutler-url",
"gitbutler-user",
"glob",
"hex",
"itertools 0.13.0",
"md5",
"once_cell",
"pretty_assertions",
"regex",
"reqwest 0.12.5",
"serde",
"serial_test",
"tempfile",
"tokio",
"tracing",
"url",
"urlencoding",
]
[[package]]
name = "gitbutler-branchstate"
version = "0.0.0"
@ -2262,6 +2306,7 @@ dependencies = [
"futures",
"git2",
"gitbutler-branch",
"gitbutler-branch-actions",
"gitbutler-command-context",
"gitbutler-config",
"gitbutler-error",
@ -2276,7 +2321,6 @@ dependencies = [
"gitbutler-tagged-string",
"gitbutler-testsupport",
"gitbutler-user",
"gitbutler-virtual",
"gitbutler-watcher",
"log",
"once_cell",
@ -2307,6 +2351,7 @@ dependencies = [
"anyhow",
"git2",
"gitbutler-branch",
"gitbutler-branch-actions",
"gitbutler-branchstate",
"gitbutler-command-context",
"gitbutler-project",
@ -2315,7 +2360,6 @@ dependencies = [
"gitbutler-storage",
"gitbutler-url",
"gitbutler-user",
"gitbutler-virtual",
"keyring",
"once_cell",
"serde_json",
@ -2349,50 +2393,6 @@ dependencies = [
"tempfile",
]
[[package]]
name = "gitbutler-virtual"
version = "0.0.0"
dependencies = [
"anyhow",
"bstr",
"diffy",
"futures",
"git2",
"git2-hooks",
"gitbutler-branch",
"gitbutler-branchstate",
"gitbutler-command-context",
"gitbutler-commit",
"gitbutler-error",
"gitbutler-git",
"gitbutler-id",
"gitbutler-oplog",
"gitbutler-project",
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-serde",
"gitbutler-tagged-string",
"gitbutler-testsupport",
"gitbutler-time",
"gitbutler-url",
"gitbutler-user",
"glob",
"hex",
"itertools 0.13.0",
"md5",
"once_cell",
"pretty_assertions",
"regex",
"reqwest 0.12.5",
"serde",
"serial_test",
"tempfile",
"tokio",
"tracing",
"url",
"urlencoding",
]
[[package]]
name = "gitbutler-watcher"
version = "0.0.0"
@ -2400,6 +2400,7 @@ dependencies = [
"anyhow",
"backoff",
"futures",
"gitbutler-branch-actions",
"gitbutler-command-context",
"gitbutler-error",
"gitbutler-notify-debouncer",
@ -2408,7 +2409,6 @@ dependencies = [
"gitbutler-reference",
"gitbutler-sync",
"gitbutler-user",
"gitbutler-virtual",
"gix",
"notify",
"thiserror",

View File

@ -6,7 +6,7 @@ members = [
"crates/gitbutler-watcher/vendor/debouncer",
"crates/gitbutler-testsupport",
"crates/gitbutler-cli",
"crates/gitbutler-virtual",
"crates/gitbutler-branch-actions",
"crates/gitbutler-sync",
"crates/gitbutler-oplog",
"crates/gitbutler-branchstate",
@ -51,7 +51,7 @@ gitbutler-git = { path = "crates/gitbutler-git" }
gitbutler-watcher = { path = "crates/gitbutler-watcher" }
gitbutler-testsupport = { path = "crates/gitbutler-testsupport" }
gitbutler-cli = { path = "crates/gitbutler-cli" }
gitbutler-virtual = { path = "crates/gitbutler-virtual" }
gitbutler-branch-actions = { path = "crates/gitbutler-branch-actions" }
gitbutler-sync = { path = "crates/gitbutler-sync" }
gitbutler-oplog = { path = "crates/gitbutler-oplog" }
gitbutler-branchstate = { path = "crates/gitbutler-branchstate" }

View File

@ -308,10 +308,10 @@ This is a list of crates/modules that we want to eliminate or split into smaller
- [gitbutler-reference](crates/gitbutler-reference/) (just bad)
- [gitbutler-storage](crates/gitbutler-storage/) (legacy way of dealing with files)
- [gitbutler-virtual](crates/gitbutler-virtual/) (contains functionality outside of the virtual branch domain (e.g. commit actions etc.))
- [gitbutler-branch-actions](crates/gitbutler-branch-actions/) (contains functionality outside of the virtual branch domain (e.g. commit actions etc.))
- [gitbutler-repository](crates/gitbutler-repository/)
- [gitbutler-branch](crates/gitbutler-branch/) (contains `diff` and `branch` contexts due to a cyclic dependency)
- [gitbutler-url](crates/gitbutler-url/) (this is a huge mess and ideally we need none of it)
- [gitbutler_repo::config](crates/gitbutler-repo/src/config.rs) (seems like the wrong abstraction)
- [gitbutler-config](crates/gitbutler-config) (this provides an API for the UI layer to read and write git config and we want none of that)
- [gitbutler_virtual::assets](crates/gitbutler-virtual/src/assets.rs) (this is a caching of things like favicons and it's clearly a UI concern that doesn't belong here)
- [gitbutler_virtual::assets](crates/gitbutler-branch-actions/src/assets.rs) (this is a caching of things like favicons and it's clearly a UI concern that doesn't belong here)

View File

@ -1,5 +1,5 @@
[package]
name = "gitbutler-virtual"
name = "gitbutler-branch-actions"
version = "0.0.0"
edition = "2021"
authors = ["GitButler <gitbutler@gitbutler.com>"]

View File

@ -17,16 +17,16 @@ use gitbutler_branch::{
ownership::BranchOwnershipClaims,
target::Target,
};
use gitbutler_branch_actions::r#virtual as virtual_branches;
use gitbutler_branch_actions::r#virtual::{
commit, integrate_upstream_commits, is_remote_branch_mergeable, list_virtual_branches,
unapply_ownership, update_branch,
};
use gitbutler_branch_actions::{branch_manager::BranchManagerAccess, integration};
use gitbutler_branchstate::VirtualBranchesExt;
use gitbutler_commit::{commit_ext::CommitExt, commit_headers::CommitHeadersV2};
use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_repo::RepositoryExt;
use gitbutler_virtual::r#virtual as virtual_branches;
use gitbutler_virtual::r#virtual::{
commit, integrate_upstream_commits, is_remote_branch_mergeable, list_virtual_branches,
unapply_ownership, update_branch,
};
use gitbutler_virtual::{branch_manager::BranchManagerAccess, integration};
use pretty_assertions::assert_eq;
use gitbutler_testsupport::{commit_all, virtual_branches::set_test_target, Case, Suite};
@ -1333,7 +1333,7 @@ fn detect_mergeable_branch() -> Result<()> {
};
vb_state.set_branch(branch4.clone())?;
let remotes = gitbutler_virtual::remote::list_remote_branches(project_repository)
let remotes = gitbutler_branch_actions::remote::list_remote_branches(project_repository)
.expect("failed to list remotes");
let _remote1 = &remotes
.iter()

View File

@ -1,6 +1,6 @@
use gitbutler_branch::branch::Branch;
use gitbutler_branch_actions::VirtualBranch;
use gitbutler_id::id::Id;
use gitbutler_virtual::VirtualBranch;
use super::*;

View File

@ -2,10 +2,10 @@ use std::path::PathBuf;
use std::{fs, path, str::FromStr};
use gitbutler_branch::branch;
use gitbutler_branch_actions::VirtualBranchActions;
use gitbutler_error::error::Marker;
use gitbutler_project::{self as projects, Project, ProjectId};
use gitbutler_reference::Refname;
use gitbutler_virtual::VirtualBranchActions;
use tempfile::TempDir;
use gitbutler_testsupport::{paths, TestProject, VAR_NO_CLEANUP};

View File

@ -46,7 +46,7 @@ tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = "0.3.17"
gitbutler-watcher.workspace = true
gitbutler-virtual.workspace = true
gitbutler-branch-actions.workspace = true
gitbutler-oplog.workspace = true
gitbutler-repo.workspace = true
gitbutler-command-context.workspace = true

View File

@ -1,11 +1,11 @@
use anyhow::{Context, Result};
use gitbutler_branch::branch::BranchId;
use gitbutler_branch_actions::conflicts;
use gitbutler_command_context::ProjectRepository;
use gitbutler_project as projects;
use gitbutler_project::ProjectId;
use gitbutler_reference::RemoteRefname;
use gitbutler_repo::{credentials::Helper, RepoActions, RepositoryExt};
use gitbutler_virtual::conflicts;
#[derive(Clone)]
pub struct App {

View File

@ -3,15 +3,15 @@ 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_error::error::Code;
use gitbutler_project as projects;
use gitbutler_project::ProjectId;
use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_tagged_string::ReferenceName;
use gitbutler_virtual::base::BaseBranch;
use gitbutler_virtual::files::RemoteBranchFile;
use gitbutler_virtual::remote::{RemoteBranch, RemoteBranchData};
use gitbutler_virtual::{NameConflitResolution, VirtualBranchActions, VirtualBranches};
use tauri::{AppHandle, Manager};
use tracing::instrument;

View File

@ -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 = gitbutler_virtual::VirtualBranchActions::default();
let vbranches = gitbutler_branch_actions::VirtualBranchActions::default();
Ok(gitbutler_watcher::Handler::new(
projects,

View File

@ -16,7 +16,7 @@ git2.workspace = true
tempfile = "3.10.1"
keyring.workspace = true
serde_json = "1.0"
gitbutler-virtual = { path = "../gitbutler-virtual" }
gitbutler-branch-actions = { path = "../gitbutler-branch-actions" }
gitbutler-repo = { path = "../gitbutler-repo" }
gitbutler-branchstate = { path = "../gitbutler-branchstate" }
gitbutler-command-context.workspace = true

View File

@ -42,8 +42,11 @@ pub mod virtual_branches {
})
.expect("failed to write target");
gitbutler_virtual::integration::update_gitbutler_integration(&vb_state, project_repository)
.expect("failed to update integration");
gitbutler_branch_actions::integration::update_gitbutler_integration(
&vb_state,
project_repository,
)
.expect("failed to update integration");
Ok(())
}

View File

@ -9,7 +9,7 @@ test = false
doctest = false
[dependencies]
gitbutler-virtual.workspace = true
gitbutler-branch-actions.workspace = true
gitbutler-sync.workspace = true
gitbutler-oplog.workspace = true
thiserror.workspace = true

View File

@ -1,8 +1,8 @@
use std::fmt::Display;
use std::path::PathBuf;
use gitbutler_branch_actions::VirtualBranches;
use gitbutler_project::ProjectId;
use gitbutler_virtual::VirtualBranches;
/// An event for internal use, as merge between [super::file_monitor::Event] and [Action].
#[derive(Debug)]

View File

@ -2,6 +2,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use anyhow::{Context, Result};
use gitbutler_branch_actions::VirtualBranches;
use gitbutler_command_context::ProjectRepository;
use gitbutler_error::error::Marker;
use gitbutler_oplog::{
@ -13,7 +14,6 @@ use gitbutler_project::ProjectId;
use gitbutler_reference::{LocalRefname, Refname};
use gitbutler_sync::cloud::sync_with_gitbutler;
use gitbutler_user as users;
use gitbutler_virtual::VirtualBranches;
use tracing::instrument;
use super::{events, Change};
@ -30,7 +30,7 @@ pub struct Handler {
// need extra protection.
projects: projects::Controller,
users: users::Controller,
vbranch_controller: gitbutler_virtual::VirtualBranchActions,
vbranch_controller: gitbutler_branch_actions::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::VirtualBranchActions,
vbranch_controller: gitbutler_branch_actions::VirtualBranchActions,
send_event: impl Fn(Change) -> Result<()> + Send + Sync + 'static,
) -> Self {
Handler {