diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 0286e84c5..455049637 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -20,6 +20,7 @@ jobs: gitbutler-cli: ${{ steps.filter.outputs.gitbutler-cli }} gitbutler-watcher: ${{ steps.filter.outputs.gitbutler-watcher }} gitbutler-branch: ${{ steps.filter.outputs.gitbutler-branch }} + gitbutler-sync: ${{ steps.filter.outputs.gitbutler-sync }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 @@ -59,6 +60,9 @@ jobs: gitbutler-branch: - *rust - 'crates/gitbutler-branch/**' + gitbutler-sync: + - *rust + - 'crates/gitbutler-sync/**' lint-node: needs: changes @@ -210,6 +214,30 @@ jobs: features: ${{ toJson(matrix.features) }} action: ${{ matrix.action }} + check-gitbutler-sync: + needs: changes + if: ${{ needs.changes.outputs.gitbutler-sync == 'true' }} + runs-on: ubuntu-latest + container: + image: ghcr.io/gitbutlerapp/ci-base-image:latest + strategy: + matrix: + action: + - test + - check + features: + - '' + - '*' + - [] + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/init-env-rust + - uses: ./.github/actions/check-crate + with: + crate: gitbutler-sync + features: ${{ toJson(matrix.features) }} + action: ${{ matrix.action }} + check-gitbutler-cli: needs: changes if: ${{ needs.changes.outputs.gitbutler-cli == 'true' }} @@ -267,6 +295,7 @@ jobs: - check-gitbutler-tauri - check-gitbutler-core - check-gitbutler-branch + - check-gitbutler-sync - check-gitbutler-git - check-gitbutler-cli - check-gitbutler-watcher diff --git a/Cargo.lock b/Cargo.lock index d2b78a8bd..e41f715e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2226,6 +2226,17 @@ dependencies = [ "walkdir", ] +[[package]] +name = "gitbutler-sync" +version = "0.0.0" +dependencies = [ + "anyhow", + "git2", + "gitbutler-core", + "itertools 0.13.0", + "tracing", +] + [[package]] name = "gitbutler-tauri" version = "0.0.0" @@ -2289,6 +2300,7 @@ dependencies = [ "gitbutler-branch", "gitbutler-core", "gitbutler-notify-debouncer", + "gitbutler-sync", "gix", "notify", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 6b12a9dae..bf31d7dde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,8 @@ members = [ "crates/gitbutler-watcher/vendor/debouncer", "crates/gitbutler-testsupport", "crates/gitbutler-cli", - "crates/gitbutler-branch", + "crates/gitbutler-branch", + "crates/gitbutler-sync", ] resolver = "2" @@ -27,6 +28,7 @@ gitbutler-watcher = { path = "crates/gitbutler-watcher" } gitbutler-testsupport = { path = "crates/gitbutler-testsupport" } gitbutler-cli ={ path = "crates/gitbutler-cli" } gitbutler-branch = { path = "crates/gitbutler-branch" } +gitbutler-sync = { path = "crates/gitbutler-sync" } [profile.release] codegen-units = 1 # Compile crates one after another so the compiler can optimize better diff --git a/crates/gitbutler-core/src/lib.rs b/crates/gitbutler-core/src/lib.rs index dd607eb0b..6acd009e4 100644 --- a/crates/gitbutler-core/src/lib.rs +++ b/crates/gitbutler-core/src/lib.rs @@ -33,7 +33,6 @@ pub mod secret; pub mod serde; pub mod ssh; pub mod storage; -pub mod synchronize; pub mod time; pub mod types; pub mod users; diff --git a/crates/gitbutler-sync/Cargo.toml b/crates/gitbutler-sync/Cargo.toml new file mode 100644 index 000000000..55d6e5796 --- /dev/null +++ b/crates/gitbutler-sync/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "gitbutler-sync" +version = "0.0.0" +edition = "2021" +authors = ["GitButler "] +publish = false + +[dependencies] +anyhow = "1.0.86" +tracing = "0.1.40" +itertools = "0.13" +git2.workspace = true +gitbutler-core.workspace = true diff --git a/crates/gitbutler-core/src/synchronize/mod.rs b/crates/gitbutler-sync/src/cloud.rs similarity index 97% rename from crates/gitbutler-core/src/synchronize/mod.rs rename to crates/gitbutler-sync/src/cloud.rs index 579881481..d6b443c53 100644 --- a/crates/gitbutler-core/src/synchronize/mod.rs +++ b/crates/gitbutler-sync/src/cloud.rs @@ -1,13 +1,13 @@ use std::time; -use crate::id::Id; -use crate::{ +use anyhow::{Context, Result}; +use gitbutler_core::id::Id; +use gitbutler_core::{ git::{self}, project_repository, projects::{self, CodePushState}, users, }; -use anyhow::{Context, Result}; use itertools::Itertools; pub async fn sync_with_gitbutler( @@ -56,7 +56,7 @@ pub async fn sync_with_gitbutler( async fn push_target( projects: &projects::Controller, 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, project_id: Id, user: &users::User, diff --git a/crates/gitbutler-sync/src/lib.rs b/crates/gitbutler-sync/src/lib.rs new file mode 100644 index 000000000..1ede32218 --- /dev/null +++ b/crates/gitbutler-sync/src/lib.rs @@ -0,0 +1 @@ +pub mod cloud; diff --git a/crates/gitbutler-watcher/Cargo.toml b/crates/gitbutler-watcher/Cargo.toml index 14a152175..0e704aa9e 100644 --- a/crates/gitbutler-watcher/Cargo.toml +++ b/crates/gitbutler-watcher/Cargo.toml @@ -11,6 +11,7 @@ doctest = false [dependencies] gitbutler-core.workspace = true gitbutler-branch.workspace = true +gitbutler-sync.workspace = true thiserror.workspace = true anyhow = "1.0.86" futures = "0.3.30" diff --git a/crates/gitbutler-watcher/src/handler.rs b/crates/gitbutler-watcher/src/handler.rs index cfd1c7147..6254923ed 100644 --- a/crates/gitbutler-watcher/src/handler.rs +++ b/crates/gitbutler-watcher/src/handler.rs @@ -6,8 +6,8 @@ use gitbutler_branch::VirtualBranches; use gitbutler_core::error::Marker; use gitbutler_core::ops::entry::{OperationKind, SnapshotDetails}; use gitbutler_core::projects::ProjectId; -use gitbutler_core::synchronize::sync_with_gitbutler; use gitbutler_core::{assets, git, project_repository, projects, users}; +use gitbutler_sync::cloud::sync_with_gitbutler; use tracing::instrument; use super::{events, Change};