From 807d68bc38fcb1858eb3779714f90b8a182ff069 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Fri, 14 Apr 2023 15:40:35 +0200 Subject: [PATCH] remove unused deps --- src-tauri/Cargo.lock | 1 - src-tauri/Cargo.toml | 1 - src-tauri/src/app/gb_repository.rs | 54 +++++++++++++++++------------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 4c62b4635..4ca99fdd3 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1320,7 +1320,6 @@ dependencies = [ "timed", "tokio", "tokio-tungstenite", - "tokio-util", "urlencoding", "uuid 1.3.0", "walkdir", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d8ee49ed9..7b307ab6f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -46,7 +46,6 @@ futures = "0.3" futures-util = "0.3.8" timed = "0.2.1" serde-jsonlines = "0.4.0" -tokio-util = "0.7.7" crossbeam-channel = "0.5.8" [features] diff --git a/src-tauri/src/app/gb_repository.rs b/src-tauri/src/app/gb_repository.rs index 1f8d1ddd4..532b57759 100644 --- a/src-tauri/src/app/gb_repository.rs +++ b/src-tauri/src/app/gb_repository.rs @@ -24,12 +24,15 @@ impl Repository { project_store: projects::Storage, ) -> Result { let path = root.as_ref().join(project_id.clone()); - let git_repository = if path.exists() { - git2::Repository::open(path.clone()) - .with_context(|| format!("{}: failed to open git repository", path.display()))? + if path.exists() { + Ok(Self { + project_id, + git_repository: git2::Repository::open(path.clone()).with_context(|| { + format!("{}: failed to open git repository", path.display()) + })?, + project_store, + }) } else { - // TODO: flush first session instead - let git_repository = git2::Repository::init_opts( &path, &git2::RepositoryInitOptions::new() @@ -38,25 +41,30 @@ impl Repository { ) .with_context(|| format!("{}: failed to initialize git repository", path.display()))?; - let mut index = git_repository.index()?; - let oid = index.write_tree()?; - let signature = git2::Signature::now("gitbutler", "gitbutler@localhost").unwrap(); - git_repository.commit( - Some("HEAD"), - &signature, - &signature, - "Initial commit", - &git_repository.find_tree(oid)?, - &[], - )?; + { + // TODO: remove this once flushing is fully working + let mut index = git_repository.index()?; + let oid = index.write_tree()?; + let signature = git2::Signature::now("gitbutler", "gitbutler@localhost").unwrap(); + git_repository.commit( + Some("HEAD"), + &signature, + &signature, + "Initial commit", + &git_repository.find_tree(oid)?, + &[], + )?; + } - git_repository - }; - Ok(Self { - project_id, - git_repository, - project_store, - }) + let gb_repository = Self { + project_id, + git_repository, + project_store, + }; + + gb_repository.flush()?; + Ok(gb_repository) + } } fn create_current_session(