Refactor - join stack and stack api crates

Separation was previously needed due to cycle dependency with the repo crate. 
The stack_ext is to be refactored as an impl on stack
This commit is contained in:
Kiril Videlov 2024-10-22 15:26:53 +02:00
parent 5b5f9b2e45
commit ccec1868f8
27 changed files with 1172 additions and 1219 deletions

29
Cargo.lock generated
View File

@ -2192,7 +2192,6 @@ dependencies = [
"gitbutler-repo-actions", "gitbutler-repo-actions",
"gitbutler-serde", "gitbutler-serde",
"gitbutler-stack", "gitbutler-stack",
"gitbutler-stack-api",
"gitbutler-testsupport", "gitbutler-testsupport",
"gitbutler-time", "gitbutler-time",
"gitbutler-url", "gitbutler-url",
@ -2316,7 +2315,6 @@ dependencies = [
"gitbutler-reference", "gitbutler-reference",
"gitbutler-repo", "gitbutler-repo",
"gitbutler-stack", "gitbutler-stack",
"gitbutler-stack-api",
"gitbutler-time", "gitbutler-time",
"serde", "serde",
] ]
@ -2584,43 +2582,26 @@ version = "0.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"git2", "git2",
"gitbutler-command-context",
"gitbutler-commit",
"gitbutler-diff", "gitbutler-diff",
"gitbutler-error", "gitbutler-error",
"gitbutler-fs", "gitbutler-fs",
"gitbutler-id",
"gitbutler-patch-reference",
"gitbutler-reference",
"gitbutler-serde",
"gitbutler-time",
"gix",
"itertools 0.13.0",
"serde",
"toml 0.8.19",
]
[[package]]
name = "gitbutler-stack-api"
version = "0.0.0"
dependencies = [
"anyhow",
"git2",
"gitbutler-branch",
"gitbutler-command-context",
"gitbutler-commit",
"gitbutler-git", "gitbutler-git",
"gitbutler-id",
"gitbutler-patch-reference", "gitbutler-patch-reference",
"gitbutler-reference", "gitbutler-reference",
"gitbutler-repo", "gitbutler-repo",
"gitbutler-repo-actions", "gitbutler-repo-actions",
"gitbutler-stack", "gitbutler-serde",
"gitbutler-testsupport", "gitbutler-testsupport",
"gitbutler-time", "gitbutler-time",
"gix", "gix",
"gix-utils 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "gix-utils 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.13.0", "itertools 0.13.0",
"rand 0.8.5",
"serde", "serde",
"tempfile", "tempfile",
"toml 0.8.19",
"tracing", "tracing",
] ]

View File

@ -33,7 +33,6 @@ members = [
"crates/gitbutler-edit-mode", "crates/gitbutler-edit-mode",
"crates/gitbutler-cherry-pick", "crates/gitbutler-cherry-pick",
"crates/gitbutler-oxidize", "crates/gitbutler-oxidize",
"crates/gitbutler-stack-api",
"crates/gitbutler-stack", "crates/gitbutler-stack",
"crates/gitbutler-patch-reference", "crates/gitbutler-patch-reference",
] ]
@ -91,7 +90,6 @@ gitbutler-operating-modes = { path = "crates/gitbutler-operating-modes" }
gitbutler-edit-mode = { path = "crates/gitbutler-edit-mode" } gitbutler-edit-mode = { path = "crates/gitbutler-edit-mode" }
gitbutler-cherry-pick = { path = "crates/gitbutler-cherry-pick" } gitbutler-cherry-pick = { path = "crates/gitbutler-cherry-pick" }
gitbutler-oxidize = { path = "crates/gitbutler-oxidize" } gitbutler-oxidize = { path = "crates/gitbutler-oxidize" }
gitbutler-stack-api = { path = "crates/gitbutler-stack-api" }
gitbutler-stack = { path = "crates/gitbutler-stack" } gitbutler-stack = { path = "crates/gitbutler-stack" }
gitbutler-patch-reference = { path = "crates/gitbutler-patch-reference" } gitbutler-patch-reference = { path = "crates/gitbutler-patch-reference" }
gitbutler-forge = { path = "crates/gitbutler-forge" } gitbutler-forge = { path = "crates/gitbutler-forge" }

View File

@ -29,7 +29,6 @@ gitbutler-operating-modes.workspace = true
gitbutler-cherry-pick.workspace = true gitbutler-cherry-pick.workspace = true
gitbutler-oxidize.workspace = true gitbutler-oxidize.workspace = true
gitbutler-stack.workspace = true gitbutler-stack.workspace = true
gitbutler-stack-api.workspace = true
gitbutler-patch-reference.workspace = true gitbutler-patch-reference.workspace = true
serde = { workspace = true, features = ["std"] } serde = { workspace = true, features = ["std"] }
bstr.workspace = true bstr.workspace = true

View File

@ -8,8 +8,8 @@ use gitbutler_project::FetchResult;
use gitbutler_reference::{Refname, RemoteRefname}; use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_repo::{LogUntil, RepositoryExt}; use gitbutler_repo::{LogUntil, RepositoryExt};
use gitbutler_repo_actions::RepoActionsExt; use gitbutler_repo_actions::RepoActionsExt;
use gitbutler_stack::StackExt;
use gitbutler_stack::{BranchOwnershipClaims, Stack, Target, VirtualBranchesHandle}; use gitbutler_stack::{BranchOwnershipClaims, Stack, Target, VirtualBranchesHandle};
use gitbutler_stack_api::StackExt;
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{

View File

@ -13,8 +13,8 @@ use gitbutler_repo::{
LogUntil, RepositoryExt, LogUntil, RepositoryExt,
}; };
use gitbutler_repo_actions::RepoActionsExt; use gitbutler_repo_actions::RepoActionsExt;
use gitbutler_stack::StackExt;
use gitbutler_stack::{BranchOwnershipClaims, Stack, StackId}; use gitbutler_stack::{BranchOwnershipClaims, Stack, StackId};
use gitbutler_stack_api::StackExt;
use gitbutler_time::time::now_since_unix_epoch_ms; use gitbutler_time::time::now_since_unix_epoch_ms;
use tracing::instrument; use tracing::instrument;

View File

@ -6,7 +6,7 @@ use gitbutler_repo::{
LogUntil, RepositoryExt as _, LogUntil, RepositoryExt as _,
}; };
use gitbutler_stack::StackId; use gitbutler_stack::StackId;
use gitbutler_stack_api::{commit_by_oid_or_change_id, StackExt}; use gitbutler_stack::{commit_by_oid_or_change_id, StackExt};
use crate::{ use crate::{
branch_trees::{ branch_trees::{

View File

@ -12,8 +12,8 @@ use gitbutler_operating_modes::OPEN_WORKSPACE_REFS;
use gitbutler_project::access::WorktreeWritePermission; use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_repo::SignaturePurpose; use gitbutler_repo::SignaturePurpose;
use gitbutler_repo::{LogUntil, RepositoryExt}; use gitbutler_repo::{LogUntil, RepositoryExt};
use gitbutler_stack::StackExt;
use gitbutler_stack::{Stack, VirtualBranchesHandle}; use gitbutler_stack::{Stack, VirtualBranchesHandle};
use gitbutler_stack_api::StackExt;
use tracing::instrument; use tracing::instrument;
use crate::{branch_manager::BranchManagerExt, conflicts, VirtualBranchesExt}; use crate::{branch_manager::BranchManagerExt, conflicts, VirtualBranchesExt};

View File

@ -7,8 +7,8 @@ use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt; use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_project::access::WorktreeWritePermission; use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt}; use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt};
use gitbutler_stack::StackExt;
use gitbutler_stack::{OwnershipClaim, StackId}; use gitbutler_stack::{OwnershipClaim, StackId};
use gitbutler_stack_api::StackExt;
use std::collections::HashMap; use std::collections::HashMap;
/// moves commit from the branch it's in to the top of the target branch /// moves commit from the branch it's in to the top of the target branch

View File

@ -2,8 +2,8 @@ use anyhow::{bail, Context as _, Result};
use gitbutler_command_context::CommandContext; use gitbutler_command_context::CommandContext;
use gitbutler_project::access::WorktreeWritePermission; use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt as _}; use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt as _};
use gitbutler_stack::StackExt;
use gitbutler_stack::StackId; use gitbutler_stack::StackId;
use gitbutler_stack_api::StackExt;
use crate::{ use crate::{
branch_trees::{ branch_trees::{

View File

@ -7,10 +7,8 @@ use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference}; use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
use gitbutler_project::Project; use gitbutler_project::Project;
use gitbutler_repo_actions::RepoActionsExt; use gitbutler_repo_actions::RepoActionsExt;
use gitbutler_stack::{commit_by_oid_or_change_id, CommitsForId, PatchReferenceUpdate, StackExt};
use gitbutler_stack::{Stack, StackId, Target}; use gitbutler_stack::{Stack, StackId, Target};
use gitbutler_stack_api::{
commit_by_oid_or_change_id, CommitsForId, PatchReferenceUpdate, StackExt,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{

View File

@ -15,8 +15,8 @@ use gitbutler_command_context::CommandContext;
use gitbutler_diff::{diff_files_into_hunks, GitHunk, Hunk, HunkHash}; use gitbutler_diff::{diff_files_into_hunks, GitHunk, Hunk, HunkHash};
use gitbutler_operating_modes::assure_open_workspace_mode; use gitbutler_operating_modes::assure_open_workspace_mode;
use gitbutler_project::access::WorktreeWritePermission; use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_stack::StackExt;
use gitbutler_stack::{BranchOwnershipClaims, OwnershipClaim, Stack, StackId}; use gitbutler_stack::{BranchOwnershipClaims, OwnershipClaim, Stack, StackId};
use gitbutler_stack_api::StackExt;
use tracing::instrument; use tracing::instrument;
/// Represents the uncommitted status of the applied virtual branches in the workspace. /// Represents the uncommitted status of the applied virtual branches in the workspace.

View File

@ -2,8 +2,8 @@ use anyhow::{bail, Context as _, Result};
use gitbutler_command_context::CommandContext; use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt as _; use gitbutler_commit::commit_ext::CommitExt as _;
use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt as _}; use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt as _};
use gitbutler_stack::StackExt;
use gitbutler_stack::{Stack, StackId}; use gitbutler_stack::{Stack, StackId};
use gitbutler_stack_api::StackExt;
use crate::VirtualBranchesExt as _; use crate::VirtualBranchesExt as _;

View File

@ -7,8 +7,8 @@ use gitbutler_repo::{
LogUntil, RepositoryExt as _, LogUntil, RepositoryExt as _,
}; };
use gitbutler_repo_actions::RepoActionsExt as _; use gitbutler_repo_actions::RepoActionsExt as _;
use gitbutler_stack::StackExt;
use gitbutler_stack::{Stack, StackId, Target, VirtualBranchesHandle}; use gitbutler_stack::{Stack, StackId, Target, VirtualBranchesHandle};
use gitbutler_stack_api::StackExt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{

View File

@ -28,10 +28,10 @@ use gitbutler_repo::{
LogUntil, RepositoryExt, LogUntil, RepositoryExt,
}; };
use gitbutler_repo_actions::RepoActionsExt; use gitbutler_repo_actions::RepoActionsExt;
use gitbutler_stack::StackExt;
use gitbutler_stack::{ use gitbutler_stack::{
reconcile_claims, BranchOwnershipClaims, Stack, StackId, Target, VirtualBranchesHandle, reconcile_claims, BranchOwnershipClaims, Stack, StackId, Target, VirtualBranchesHandle,
}; };
use gitbutler_stack_api::StackExt;
use gitbutler_time::time::now_since_unix_epoch_ms; use gitbutler_time::time::now_since_unix_epoch_ms;
use serde::Serialize; use serde::Serialize;
use std::collections::HashSet; use std::collections::HashSet;

View File

@ -20,8 +20,8 @@ use gitbutler_branch_actions::{
use gitbutler_commit::{commit_ext::CommitExt, commit_headers::CommitHeadersV2}; use gitbutler_commit::{commit_ext::CommitExt, commit_headers::CommitHeadersV2};
use gitbutler_reference::{Refname, RemoteRefname}; use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_repo::RepositoryExt; use gitbutler_repo::RepositoryExt;
use gitbutler_stack::StackExt;
use gitbutler_stack::{BranchOwnershipClaims, Target, VirtualBranchesHandle}; use gitbutler_stack::{BranchOwnershipClaims, Target, VirtualBranchesHandle};
use gitbutler_stack_api::StackExt;
use gitbutler_testsupport::{commit_all, virtual_branches::set_test_target, Case, Suite}; use gitbutler_testsupport::{commit_all, virtual_branches::set_test_target, Case, Suite};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;

View File

@ -22,5 +22,4 @@ gitbutler-oplog.workspace = true
gitbutler-diff.workspace = true gitbutler-diff.workspace = true
gitbutler-stack.workspace = true gitbutler-stack.workspace = true
gitbutler-cherry-pick.workspace = true gitbutler-cherry-pick.workspace = true
gitbutler-stack-api.workspace = true
serde.workspace = true serde.workspace = true

View File

@ -25,8 +25,8 @@ use gitbutler_project::access::{WorktreeReadPermission, WorktreeWritePermission}
use gitbutler_reference::{ReferenceName, Refname}; use gitbutler_reference::{ReferenceName, Refname};
use gitbutler_repo::{rebase::cherry_rebase, RepositoryExt}; use gitbutler_repo::{rebase::cherry_rebase, RepositoryExt};
use gitbutler_repo::{signature, SignaturePurpose}; use gitbutler_repo::{signature, SignaturePurpose};
use gitbutler_stack::StackExt;
use gitbutler_stack::{Stack, VirtualBranchesHandle}; use gitbutler_stack::{Stack, VirtualBranchesHandle};
use gitbutler_stack_api::StackExt;
use serde::Serialize; use serde::Serialize;
pub mod commands; pub mod commands;

View File

@ -1,34 +0,0 @@
[package]
name = "gitbutler-stack-api"
version = "0.0.0"
edition = "2021"
authors = ["GitButler <gitbutler@gitbutler.com>"]
publish = false
[dependencies]
anyhow = "1.0.86"
itertools = "0.13"
rand = "0.8.5"
gix-utils = "0.1.12"
serde = { workspace = true, features = ["std"] }
git2.workspace = true
gix.workspace = true
tracing.workspace = true
gitbutler-command-context.workspace = true
gitbutler-branch.workspace = true
gitbutler-patch-reference.workspace = true
gitbutler-reference.workspace = true
gitbutler-repo.workspace = true
gitbutler-commit.workspace = true
gitbutler-time.workspace = true
gitbutler-stack.workspace = true
[[test]]
name = "stack-api"
path = "tests/mod.rs"
[dev-dependencies]
gitbutler-git = { workspace = true, features = ["test-askpass-path"] }
gitbutler-testsupport.workspace = true
gitbutler-repo-actions.workspace = true
tempfile = "3.13"

View File

@ -1,7 +0,0 @@
mod heads;
mod series;
mod stack_ext;
pub use series::Series;
pub use stack_ext::{
commit_by_oid_or_change_id, CommitsForId, PatchReferenceUpdate, StackExt, TargetUpdate,
};

File diff suppressed because it is too large Load Diff

View File

@ -8,10 +8,12 @@ publish = false
[dependencies] [dependencies]
git2.workspace = true git2.workspace = true
gix = { workspace = true, features = [] } gix = { workspace = true, features = [] }
gix-utils = "0.1.12"
itertools = "0.13" itertools = "0.13"
anyhow = "1.0.86" anyhow = "1.0.86"
serde = { workspace = true, features = ["std"] } serde = { workspace = true, features = ["std"] }
toml.workspace = true toml.workspace = true
tracing.workspace = true
gitbutler-patch-reference.workspace = true gitbutler-patch-reference.workspace = true
gitbutler-reference.workspace = true gitbutler-reference.workspace = true
gitbutler-id.workspace = true gitbutler-id.workspace = true
@ -20,7 +22,16 @@ gitbutler-time.workspace = true
gitbutler-diff.workspace = true gitbutler-diff.workspace = true
gitbutler-error.workspace = true gitbutler-error.workspace = true
gitbutler-fs.workspace = true gitbutler-fs.workspace = true
gitbutler-command-context.workspace = true
gitbutler-repo.workspace = true
gitbutler-commit.workspace = true
[[test]] [[test]]
name = "branch" name = "stack"
path = "tests/mod.rs" path = "tests/mod.rs"
[dev-dependencies]
gitbutler-git = { workspace = true, features = ["test-askpass-path"] } # Runtime test dependency
gitbutler-testsupport.workspace = true
gitbutler-repo-actions.workspace = true
tempfile = "3.13"

View File

@ -9,3 +9,11 @@ pub use ownership::{reconcile_claims, BranchOwnershipClaims, ClaimOutcome};
pub use stack::{Stack, StackId}; pub use stack::{Stack, StackId};
pub use state::{VirtualBranches as VirtualBranchesState, VirtualBranchesHandle}; pub use state::{VirtualBranches as VirtualBranchesState, VirtualBranchesHandle};
pub use target::Target; pub use target::Target;
mod heads;
mod series;
mod stack_ext;
pub use series::Series;
pub use stack_ext::{
commit_by_oid_or_change_id, CommitsForId, PatchReferenceUpdate, StackExt, TargetUpdate,
};

View File

@ -1,5 +1,7 @@
use std::str::FromStr; use std::str::FromStr;
use crate::Stack;
use crate::VirtualBranchesHandle;
use anyhow::anyhow; use anyhow::anyhow;
use anyhow::bail; use anyhow::bail;
use anyhow::Context; use anyhow::Context;
@ -13,8 +15,6 @@ use gitbutler_reference::Refname;
use gitbutler_reference::RemoteRefname; use gitbutler_reference::RemoteRefname;
use gitbutler_repo::LogUntil; use gitbutler_repo::LogUntil;
use gitbutler_repo::RepositoryExt; use gitbutler_repo::RepositoryExt;
use gitbutler_stack::Stack;
use gitbutler_stack::VirtualBranchesHandle;
use gix::validate::reference::name_partial; use gix::validate::reference::name_partial;
use gix_utils::str::decompose; use gix_utils::str::decompose;
use itertools::Itertools; use itertools::Itertools;

File diff suppressed because it is too large Load Diff