Merge pull request #4259 from gitbutlerapp/add-gitbutler-sync-crate

move cloud sync functionality to its own crate
This commit is contained in:
Kiril Videlov 2024-07-07 19:38:25 +02:00 committed by GitHub
commit b286a6e2d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 64 additions and 7 deletions

View File

@ -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

12
Cargo.lock generated
View File

@ -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",

View File

@ -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

View File

@ -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;

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 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<git2::Oid>,
project_id: Id<projects::Project>,
user: &users::User,

View File

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

View File

@ -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"

View File

@ -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};