mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-08-16 15:50:37 +03:00
remove project dependency on oplog
This commit is contained in:
parent
1c9b702993
commit
71809fc882
@ -10,7 +10,8 @@ use crate::integration::{get_workspace_head, update_gitbutler_integration};
|
||||
use crate::remote::{commit_to_remote_commit, RemoteCommit};
|
||||
use crate::VirtualBranchHunk;
|
||||
use gitbutler_core::virtual_branches::{
|
||||
branch, target, BranchId, VirtualBranchesHandle, GITBUTLER_INTEGRATION_REFERENCE,
|
||||
branch, target, BranchId, VirtualBranchesAccess, VirtualBranchesHandle,
|
||||
GITBUTLER_INTEGRATION_REFERENCE,
|
||||
};
|
||||
use gitbutler_core::{error::Marker, git::RepositoryExt, rebase::cherry_rebase};
|
||||
use gitbutler_core::{
|
||||
|
@ -4,6 +4,7 @@ use gitbutler_core::{
|
||||
project_repository::Repository,
|
||||
projects::FetchResult,
|
||||
types::ReferenceName,
|
||||
virtual_branches::VirtualBranchesAccess,
|
||||
};
|
||||
use gitbutler_oplog::{
|
||||
entry::{OperationKind, SnapshotDetails},
|
||||
|
@ -6,7 +6,7 @@ use bstr::ByteSlice;
|
||||
use gitbutler_core::error::Marker;
|
||||
use gitbutler_core::git::RepositoryExt;
|
||||
use gitbutler_core::virtual_branches::{
|
||||
VirtualBranchesHandle, GITBUTLER_INTEGRATION_COMMIT_AUTHOR_EMAIL,
|
||||
VirtualBranchesAccess, VirtualBranchesHandle, GITBUTLER_INTEGRATION_COMMIT_AUTHOR_EMAIL,
|
||||
GITBUTLER_INTEGRATION_COMMIT_AUTHOR_NAME, GITBUTLER_INTEGRATION_REFERENCE,
|
||||
};
|
||||
use gitbutler_core::{
|
||||
|
@ -15,7 +15,7 @@ use diffy::{apply_bytes as diffy_apply, Line, Patch};
|
||||
use git2::build::TreeUpdateBuilder;
|
||||
use git2::ErrorCode;
|
||||
use git2_hooks::HookResult;
|
||||
use gitbutler_core::virtual_branches::Author;
|
||||
use gitbutler_core::virtual_branches::{Author, VirtualBranchesAccess};
|
||||
use hex::ToHex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -19,7 +19,10 @@ use gitbutler_branch::r#virtual::{
|
||||
};
|
||||
use gitbutler_core::{
|
||||
git::{self, CommitExt, RepositoryExt},
|
||||
virtual_branches::branch::{BranchCreateRequest, BranchOwnershipClaims, BranchUpdateRequest},
|
||||
virtual_branches::{
|
||||
branch::{BranchCreateRequest, BranchOwnershipClaims, BranchUpdateRequest},
|
||||
VirtualBranchesAccess,
|
||||
},
|
||||
};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use gitbutler_core::virtual_branches::VirtualBranchesAccess;
|
||||
use gitbutler_oplog::oplog::Oplog;
|
||||
use itertools::Itertools;
|
||||
use std::io::Write;
|
||||
|
@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{id::Id, types::default_true::DefaultTrue, virtual_branches::VirtualBranchesHandle};
|
||||
use crate::{id::Id, types::default_true::DefaultTrue};
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -117,11 +117,6 @@ impl Project {
|
||||
self.path.join(".git").join("gitbutler")
|
||||
}
|
||||
|
||||
/// Returns a handle to the virtual branches manager of the project.
|
||||
pub fn virtual_branches(&self) -> VirtualBranchesHandle {
|
||||
VirtualBranchesHandle::new(self.gb_dir())
|
||||
}
|
||||
|
||||
pub fn snapshot_lines_threshold(&self) -> usize {
|
||||
self.snapshot_lines_threshold.unwrap_or(20)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ pub mod target;
|
||||
|
||||
mod state;
|
||||
pub use state::VirtualBranches as VirtualBranchesState;
|
||||
pub use state::VirtualBranchesAccess;
|
||||
pub use state::VirtualBranchesHandle;
|
||||
|
||||
mod author;
|
||||
|
@ -3,7 +3,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::{error::Code, fs::read_toml_file_or_default};
|
||||
use crate::{error::Code, fs::read_toml_file_or_default, projects::Project};
|
||||
use anyhow::{anyhow, Result};
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -29,6 +29,16 @@ pub struct VirtualBranchesHandle {
|
||||
file_path: PathBuf,
|
||||
}
|
||||
|
||||
pub trait VirtualBranchesAccess {
|
||||
fn virtual_branches(&self) -> VirtualBranchesHandle;
|
||||
}
|
||||
|
||||
impl VirtualBranchesAccess for Project {
|
||||
fn virtual_branches(&self) -> VirtualBranchesHandle {
|
||||
VirtualBranchesHandle::new(self.gb_dir())
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualBranchesHandle {
|
||||
/// Creates a new concurrency-safe handle to the state of virtual branches.
|
||||
pub fn new<P: AsRef<Path>>(base_path: P) -> Self {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
use anyhow::Result;
|
||||
use gitbutler_core::virtual_branches;
|
||||
use gitbutler_core::virtual_branches::{self, VirtualBranchesAccess};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use gitbutler_testsupport::{Case, Suite};
|
||||
|
@ -11,7 +11,8 @@ use tracing::instrument;
|
||||
|
||||
use gitbutler_core::git::diff::FileDiff;
|
||||
use gitbutler_core::virtual_branches::{
|
||||
Branch, GITBUTLER_INTEGRATION_COMMIT_AUTHOR_EMAIL, GITBUTLER_INTEGRATION_COMMIT_AUTHOR_NAME,
|
||||
Branch, VirtualBranchesAccess, GITBUTLER_INTEGRATION_COMMIT_AUTHOR_EMAIL,
|
||||
GITBUTLER_INTEGRATION_COMMIT_AUTHOR_NAME,
|
||||
};
|
||||
use gitbutler_core::{git::diff::hunks_by_filepath, git::RepositoryExt, projects::Project};
|
||||
|
||||
|
@ -2,6 +2,7 @@ use std::time;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use gitbutler_core::id::Id;
|
||||
use gitbutler_core::virtual_branches::VirtualBranchesAccess;
|
||||
use gitbutler_core::{
|
||||
git::{self},
|
||||
project_repository,
|
||||
|
@ -18,7 +18,10 @@ pub mod paths {
|
||||
}
|
||||
|
||||
pub mod virtual_branches {
|
||||
use gitbutler_core::{project_repository, virtual_branches};
|
||||
use gitbutler_core::{
|
||||
project_repository,
|
||||
virtual_branches::{self, VirtualBranchesAccess},
|
||||
};
|
||||
|
||||
use crate::empty_bare_repository;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user