move cloud sync functionality to its own crate

This commit is contained in:
Kiril Videlov 2024-07-07 19:22:41 +02:00
parent 832ef485c4
commit d456ba5e77
No known key found for this signature in database
GPG Key ID: A4C733025427C471
8 changed files with 35 additions and 7 deletions

12
Cargo.lock generated
View File

@ -2226,6 +2226,17 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "gitbutler-sync"
version = "0.0.0"
dependencies = [
"anyhow",
"git2",
"gitbutler-core",
"itertools 0.13.0",
"tracing",
]
[[package]] [[package]]
name = "gitbutler-tauri" name = "gitbutler-tauri"
version = "0.0.0" version = "0.0.0"
@ -2289,6 +2300,7 @@ dependencies = [
"gitbutler-branch", "gitbutler-branch",
"gitbutler-core", "gitbutler-core",
"gitbutler-notify-debouncer", "gitbutler-notify-debouncer",
"gitbutler-sync",
"gix", "gix",
"notify", "notify",
"thiserror", "thiserror",

View File

@ -7,7 +7,8 @@ members = [
"crates/gitbutler-watcher/vendor/debouncer", "crates/gitbutler-watcher/vendor/debouncer",
"crates/gitbutler-testsupport", "crates/gitbutler-testsupport",
"crates/gitbutler-cli", "crates/gitbutler-cli",
"crates/gitbutler-branch", "crates/gitbutler-branch",
"crates/gitbutler-sync",
] ]
resolver = "2" resolver = "2"
@ -27,6 +28,7 @@ gitbutler-watcher = { path = "crates/gitbutler-watcher" }
gitbutler-testsupport = { path = "crates/gitbutler-testsupport" } gitbutler-testsupport = { path = "crates/gitbutler-testsupport" }
gitbutler-cli ={ path = "crates/gitbutler-cli" } gitbutler-cli ={ path = "crates/gitbutler-cli" }
gitbutler-branch = { path = "crates/gitbutler-branch" } gitbutler-branch = { path = "crates/gitbutler-branch" }
gitbutler-sync = { path = "crates/gitbutler-sync" }
[profile.release] [profile.release]
codegen-units = 1 # Compile crates one after another so the compiler can optimize better codegen-units = 1 # Compile crates one after another so the compiler can optimize better

View File

@ -33,7 +33,6 @@ pub mod secret;
pub mod serde; pub mod serde;
pub mod ssh; pub mod ssh;
pub mod storage; pub mod storage;
pub mod synchronize;
pub mod time; pub mod time;
pub mod types; pub mod types;
pub mod users; pub mod users;

View File

@ -0,0 +1,13 @@
[package]
name = "gitbutler-sync"
version = "0.0.0"
edition = "2021"
authors = ["GitButler <gitbutler@gitbutler.com>"]
publish = false
[dependencies]
anyhow = "1.0.86"
tracing = "0.1.40"
itertools = "0.13"
git2.workspace = true
gitbutler-core.workspace = true

View File

@ -1,13 +1,13 @@
use std::time; use std::time;
use crate::id::Id; use anyhow::{Context, Result};
use crate::{ use gitbutler_core::id::Id;
use gitbutler_core::{
git::{self}, git::{self},
project_repository, project_repository,
projects::{self, CodePushState}, projects::{self, CodePushState},
users, users,
}; };
use anyhow::{Context, Result};
use itertools::Itertools; use itertools::Itertools;
pub async fn sync_with_gitbutler( pub async fn sync_with_gitbutler(
@ -56,7 +56,7 @@ pub async fn sync_with_gitbutler(
async fn push_target( async fn push_target(
projects: &projects::Controller, projects: &projects::Controller,
project_repository: &project_repository::Repository, project_repository: &project_repository::Repository,
default_target: &crate::virtual_branches::target::Target, default_target: &gitbutler_core::virtual_branches::target::Target,
gb_code_last_commit: Option<git2::Oid>, gb_code_last_commit: Option<git2::Oid>,
project_id: Id<projects::Project>, project_id: Id<projects::Project>,
user: &users::User, user: &users::User,

View File

@ -0,0 +1 @@
pub mod cloud;

View File

@ -11,6 +11,7 @@ doctest = false
[dependencies] [dependencies]
gitbutler-core.workspace = true gitbutler-core.workspace = true
gitbutler-branch.workspace = true gitbutler-branch.workspace = true
gitbutler-sync.workspace = true
thiserror.workspace = true thiserror.workspace = true
anyhow = "1.0.86" anyhow = "1.0.86"
futures = "0.3.30" futures = "0.3.30"

View File

@ -6,8 +6,8 @@ use gitbutler_branch::VirtualBranches;
use gitbutler_core::error::Marker; use gitbutler_core::error::Marker;
use gitbutler_core::ops::entry::{OperationKind, SnapshotDetails}; use gitbutler_core::ops::entry::{OperationKind, SnapshotDetails};
use gitbutler_core::projects::ProjectId; use gitbutler_core::projects::ProjectId;
use gitbutler_core::synchronize::sync_with_gitbutler;
use gitbutler_core::{assets, git, project_repository, projects, users}; use gitbutler_core::{assets, git, project_repository, projects, users};
use gitbutler_sync::cloud::sync_with_gitbutler;
use tracing::instrument; use tracing::instrument;
use super::{events, Change}; use super::{events, Change};