extract the Branch types to crate gitbutler-stack

This commit is contained in:
Kiril Videlov 2024-10-08 15:27:16 +02:00
parent d78ebbe176
commit 7ec59f8489
84 changed files with 175 additions and 103 deletions

31
Cargo.lock generated
View File

@ -2151,6 +2151,7 @@ dependencies = [
"gitbutler-patch-reference",
"gitbutler-reference",
"gitbutler-serde",
"gitbutler-stack",
"gitbutler-time",
"gix",
"hex",
@ -2189,6 +2190,7 @@ dependencies = [
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-serde",
"gitbutler-stack",
"gitbutler-stack-api",
"gitbutler-testsupport",
"gitbutler-time",
@ -2237,6 +2239,7 @@ dependencies = [
"gitbutler-oplog",
"gitbutler-project",
"gitbutler-reference",
"gitbutler-stack",
"gix",
"tracing",
"tracing-forest",
@ -2310,6 +2313,7 @@ dependencies = [
"gitbutler-project",
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-stack",
"gitbutler-time",
"serde",
]
@ -2419,6 +2423,7 @@ dependencies = [
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-serde",
"gitbutler-stack",
"gix",
"itertools 0.13.0",
"pretty_assertions",
@ -2500,6 +2505,7 @@ dependencies = [
"gitbutler-oxidize",
"gitbutler-project",
"gitbutler-reference",
"gitbutler-stack",
"gitbutler-testsupport",
"gitbutler-time",
"gitbutler-url",
@ -2539,6 +2545,27 @@ dependencies = [
"serde",
]
[[package]]
name = "gitbutler-stack"
version = "0.0.0"
dependencies = [
"anyhow",
"bstr",
"git2",
"gitbutler-diff",
"gitbutler-error",
"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"
@ -2552,6 +2579,7 @@ dependencies = [
"gitbutler-patch-reference",
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-stack",
"gitbutler-testsupport",
"gix",
"itertools 0.13.0",
@ -2580,6 +2608,7 @@ dependencies = [
"gitbutler-oplog",
"gitbutler-project",
"gitbutler-reference",
"gitbutler-stack",
"gitbutler-url",
"gitbutler-user",
"itertools 0.13.0",
@ -2620,6 +2649,7 @@ dependencies = [
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-secret",
"gitbutler-stack",
"gitbutler-storage",
"gitbutler-testsupport",
"gitbutler-user",
@ -2663,6 +2693,7 @@ dependencies = [
"gitbutler-project",
"gitbutler-reference",
"gitbutler-repo",
"gitbutler-stack",
"gitbutler-storage",
"gitbutler-url",
"gitbutler-user",

View File

@ -33,6 +33,7 @@ members = [
"crates/gitbutler-cherry-pick",
"crates/gitbutler-oxidize",
"crates/gitbutler-stack-api",
"crates/gitbutler-stack",
"crates/gitbutler-patch-reference",
]
resolver = "2"
@ -89,6 +90,7 @@ gitbutler-edit-mode = { path = "crates/gitbutler-edit-mode" }
gitbutler-cherry-pick = { path = "crates/gitbutler-cherry-pick" }
gitbutler-oxidize = { path = "crates/gitbutler-oxidize" }
gitbutler-stack-api = { path = "crates/gitbutler-stack-api" }
gitbutler-stack = { path = "crates/gitbutler-stack" }
gitbutler-patch-reference = { path = "crates/gitbutler-patch-reference" }
[profile.release]

View File

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

View File

@ -15,7 +15,6 @@ use crate::{
VirtualBranchesExt,
};
use anyhow::{Context, Result};
use gitbutler_branch::{BranchCreateRequest, BranchId, BranchOwnershipClaims, BranchUpdateRequest};
use gitbutler_command_context::CommandContext;
use gitbutler_diff::DiffByPathMap;
use gitbutler_operating_modes::assure_open_workspace_mode;
@ -26,6 +25,7 @@ use gitbutler_oplog::{
use gitbutler_project::{FetchResult, Project};
use gitbutler_reference::{ReferenceName, Refname, RemoteRefname};
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
use gitbutler_stack::{BranchCreateRequest, BranchId, BranchOwnershipClaims, BranchUpdateRequest};
use std::path::PathBuf;
use tracing::instrument;

View File

@ -2,15 +2,13 @@ use std::{path::Path, time};
use anyhow::{anyhow, Context, Result};
use git2::Index;
use gitbutler_branch::{
self, Branch, BranchOwnershipClaims, Target, VirtualBranchesHandle,
GITBUTLER_WORKSPACE_REFERENCE,
};
use gitbutler_branch::{self, GITBUTLER_WORKSPACE_REFERENCE};
use gitbutler_command_context::CommandContext;
use gitbutler_error::error::Marker;
use gitbutler_project::{access::WorktreeWritePermission, FetchResult};
use gitbutler_reference::{ReferenceName, Refname, RemoteRefname};
use gitbutler_repo::{rebase::cherry_rebase, LogUntil, RepoActionsExt, RepositoryExt};
use gitbutler_stack::{Branch, BranchOwnershipClaims, Target, VirtualBranchesHandle};
use serde::Serialize;
use crate::{

View File

@ -2,9 +2,7 @@ use crate::{RemoteBranchFile, VirtualBranchesExt};
use anyhow::{bail, Context, Result};
use bstr::{BStr, ByteSlice};
use core::fmt;
use gitbutler_branch::{
Branch as GitButlerBranch, BranchId, BranchIdentity, ReferenceExtGix, Target,
};
use gitbutler_branch::ReferenceExtGix;
use gitbutler_command_context::CommandContext;
use gitbutler_diff::DiffByPathMap;
use gitbutler_oxidize::{git2_to_gix_object_id, gix_to_git2_oid};
@ -12,6 +10,7 @@ use gitbutler_project::access::WorktreeReadPermission;
use gitbutler_reference::normalize_branch_name;
use gitbutler_repo::{GixRepositoryExt, RepositoryExt as _};
use gitbutler_serde::BStringForFrontend;
use gitbutler_stack::{Branch as GitButlerBranch, BranchId, BranchIdentity, Target};
use gix::object::tree::diff::Action;
use gix::prelude::ObjectIdExt;
use gix::reference::Category;

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use crate::{branch_trees::checkout_branch_trees, r#virtual as vbranch};
use anyhow::{anyhow, bail, Context, Result};
use gitbutler_branch::{self, dedup, Branch, BranchCreateRequest, BranchId, BranchOwnershipClaims};
use gitbutler_branch::{self, dedup};
use gitbutler_cherry_pick::RepositoryExt as _;
use gitbutler_commit::{commit_ext::CommitExt, commit_headers::HasCommitHeaders};
use gitbutler_error::error::Marker;
@ -13,6 +13,7 @@ use gitbutler_repo::{
rebase::{cherry_rebase_group, gitbutler_merge_commits},
LogUntil, RepoActionsExt, RepositoryExt,
};
use gitbutler_stack::{Branch, BranchCreateRequest, BranchId, BranchOwnershipClaims};
use gitbutler_time::time::now_since_unix_epoch_ms;
use tracing::instrument;

View File

@ -2,12 +2,13 @@ use std::path::PathBuf;
use anyhow::{Context, Result};
use git2::Commit;
use gitbutler_branch::{Branch, BranchExt, BranchId, SignaturePurpose};
use gitbutler_branch::{BranchExt, SignaturePurpose};
use gitbutler_commit::commit_headers::CommitHeadersV2;
use gitbutler_oplog::SnapshotExt;
use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_reference::{normalize_branch_name, ReferenceName, Refname};
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
use gitbutler_stack::{Branch, BranchId};
use tracing::instrument;
use super::BranchManager;

View File

@ -1,11 +1,11 @@
use anyhow::{bail, Result};
use gitbutler_branch::Branch;
use gitbutler_cherry_pick::RepositoryExt;
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt as _;
use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_repo::rebase::cherry_rebase_group;
use gitbutler_repo::RepositoryExt as _;
use gitbutler_stack::Branch;
use crate::VirtualBranchesExt as _;
@ -156,9 +156,9 @@ pub fn compute_updated_branch_head_for_commits(
mod test {
use std::fs;
use gitbutler_branch::BranchCreateRequest;
use gitbutler_command_context::CommandContext;
use gitbutler_repo::RepositoryExt as _;
use gitbutler_stack::BranchCreateRequest;
use gitbutler_testsupport::{paths, testing_repository::assert_tree_matches, TestProject};
#[test]

View File

@ -3,10 +3,10 @@ use crate::{
file::{list_virtual_commit_files, VirtualBranchFile},
};
use anyhow::{Context, Result};
use gitbutler_branch::{Branch, BranchId};
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_serde::BStringForFrontend;
use gitbutler_stack::{Branch, BranchId};
use serde::Serialize;
// this is the struct that maps to the view `Commit` type in Typescript

View File

@ -5,9 +5,9 @@ use std::{
time::SystemTime,
};
use gitbutler_branch::BranchId;
use gitbutler_diff::{GitHunk, Hunk, HunkHash};
use gitbutler_serde::BStringForFrontend;
use gitbutler_stack::BranchId;
use itertools::Itertools;
use md5::Digest;
use serde::Serialize;

View File

@ -2,10 +2,7 @@ use std::{path::PathBuf, vec};
use anyhow::{anyhow, Context, Result};
use bstr::ByteSlice;
use gitbutler_branch::{
self, Branch, BranchCreateRequest, SignaturePurpose, VirtualBranchesHandle,
GITBUTLER_WORKSPACE_REFERENCE,
};
use gitbutler_branch::{self, SignaturePurpose, GITBUTLER_WORKSPACE_REFERENCE};
use gitbutler_cherry_pick::RepositoryExt as _;
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt;
@ -13,6 +10,7 @@ use gitbutler_error::error::Marker;
use gitbutler_operating_modes::OPEN_WORKSPACE_REFS;
use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_repo::{LogUntil, RepositoryExt};
use gitbutler_stack::{Branch, BranchCreateRequest, VirtualBranchesHandle};
use tracing::instrument;
use crate::{branch_manager::BranchManagerExt, conflicts, VirtualBranchesExt};

View File

@ -50,7 +50,7 @@ mod undo_commit;
mod author;
mod status;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_stack::VirtualBranchesHandle;
pub use status::get_applied_status;
trait VirtualBranchesExt {
fn virtual_branches(&self) -> VirtualBranchesHandle;

View File

@ -3,11 +3,11 @@ use crate::{
VirtualBranchesExt,
};
use anyhow::{anyhow, bail, Context, Result};
use gitbutler_branch::{BranchId, OwnershipClaim};
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt};
use gitbutler_stack::{BranchId, OwnershipClaim};
use std::collections::HashMap;
/// moves commit from the branch it's in to the top of the target branch

View File

@ -2,12 +2,13 @@ use std::path::Path;
use crate::author::Author;
use anyhow::{Context, Result};
use gitbutler_branch::{ReferenceExt, Target, VirtualBranchesHandle};
use gitbutler_branch::ReferenceExt;
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_repo::{LogUntil, RepoActionsExt, RepositoryExt};
use gitbutler_serde::BStringForFrontend;
use gitbutler_stack::{Target, VirtualBranchesHandle};
use serde::Serialize;
/// this struct is a mapping to the view `RemoteBranch` type in Typescript

View File

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

View File

@ -1,8 +1,8 @@
use anyhow::{Context, Result};
use gitbutler_branch::BranchId;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
use gitbutler_project::Project;
use gitbutler_stack::BranchId;
use gitbutler_stack_api::{PatchReferenceUpdate, Stack};
use serde::{Deserialize, Serialize};

View File

@ -9,14 +9,14 @@ use crate::{
};
use anyhow::{bail, Context, Result};
use git2::Tree;
use gitbutler_branch::{
Branch, BranchCreateRequest, BranchId, BranchOwnershipClaims, OwnershipClaim,
};
use gitbutler_cherry_pick::RepositoryExt as _;
use gitbutler_command_context::CommandContext;
use gitbutler_diff::{diff_files_into_hunks, GitHunk, Hunk, HunkHash};
use gitbutler_operating_modes::assure_open_workspace_mode;
use gitbutler_project::access::WorktreeWritePermission;
use gitbutler_stack::{
Branch, BranchCreateRequest, BranchId, BranchOwnershipClaims, OwnershipClaim,
};
use gitbutler_stack_api::Stack;
use tracing::instrument;

View File

@ -1,8 +1,8 @@
use anyhow::{bail, Context as _, Result};
use gitbutler_branch::{Branch, BranchId};
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt as _;
use gitbutler_repo::{rebase::cherry_rebase_group, LogUntil, RepositoryExt as _};
use gitbutler_stack::{Branch, BranchId};
use crate::VirtualBranchesExt as _;

View File

@ -1,5 +1,4 @@
use anyhow::{anyhow, bail, Result};
use gitbutler_branch::{Branch, BranchId, Target, VirtualBranchesHandle};
use gitbutler_cherry_pick::RepositoryExt as _;
use gitbutler_command_context::CommandContext;
use gitbutler_project::access::WorktreeWritePermission;
@ -7,6 +6,7 @@ use gitbutler_repo::{
rebase::{cherry_rebase_group, gitbutler_merge_commits},
LogUntil, RepoActionsExt as _, RepositoryExt as _,
};
use gitbutler_stack::{Branch, BranchId, Target, VirtualBranchesHandle};
use serde::{Deserialize, Serialize};
use crate::{

View File

@ -11,10 +11,7 @@ use crate::{
use anyhow::{anyhow, bail, Context, Result};
use bstr::{BString, ByteSlice};
use git2_hooks::HookResult;
use gitbutler_branch::{
dedup, dedup_fmt, reconcile_claims, Branch, BranchId, BranchOwnershipClaims,
BranchUpdateRequest, Target, VirtualBranchesHandle,
};
use gitbutler_branch::{dedup, dedup_fmt};
use gitbutler_cherry_pick::RepositoryExt as _;
use gitbutler_command_context::CommandContext;
use gitbutler_commit::{commit_ext::CommitExt, commit_headers::HasCommitHeaders};
@ -28,6 +25,10 @@ use gitbutler_repo::{
rebase::{cherry_rebase, cherry_rebase_group},
LogUntil, RepoActionsExt, RepositoryExt,
};
use gitbutler_stack::{
reconcile_claims, Branch, BranchId, BranchOwnershipClaims, BranchUpdateRequest, Target,
VirtualBranchesHandle,
};
use gitbutler_stack_api::{commit_by_oid_or_change_id, Stack};
use gitbutler_time::time::now_since_unix_epoch_ms;
use serde::Serialize;

View File

@ -13,15 +13,15 @@ use std::{
use anyhow::{Context, Result};
use bstr::ByteSlice;
use git2::TreeEntry;
use gitbutler_branch::{
BranchCreateRequest, BranchOwnershipClaims, BranchUpdateRequest, Target, VirtualBranchesHandle,
};
use gitbutler_branch_actions::{
get_applied_status, internal, update_workspace_commit, verify_branch, BranchManagerExt, Get,
};
use gitbutler_commit::{commit_ext::CommitExt, commit_headers::CommitHeadersV2};
use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_repo::RepositoryExt;
use gitbutler_stack::{
BranchCreateRequest, BranchOwnershipClaims, BranchUpdateRequest, Target, VirtualBranchesHandle,
};
use gitbutler_testsupport::{commit_all, virtual_branches::set_test_target, Case, Suite};
use pretty_assertions::assert_eq;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::{BranchCreateRequest, BranchOwnershipClaims, BranchUpdateRequest};
use gitbutler_stack::{BranchCreateRequest, BranchOwnershipClaims, BranchUpdateRequest};
use super::*;

View File

@ -1,5 +1,5 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_reference::Refname;
use gitbutler_stack::BranchCreateRequest;
use super::*;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::Branch;
use gitbutler_stack::Branch;
/// Makes a Branch struct with a bunch of default values.
///

View File

@ -1,6 +1,6 @@
use gitbutler_branch::{Branch, BranchCreateRequest, BranchUpdateRequest};
use gitbutler_branch_actions::VirtualBranch;
use gitbutler_id::id::Id;
use gitbutler_stack::{Branch, BranchCreateRequest, BranchUpdateRequest};
use super::*;

View File

@ -1,5 +1,5 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_reference::LocalRefname;
use gitbutler_stack::BranchCreateRequest;
use super::*;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::*;

View File

@ -137,9 +137,9 @@ fn one_branch_in_workspace_multiple_remotes() -> Result<()> {
mod util {
use anyhow::Result;
use gitbutler_branch::BranchIdentity;
use gitbutler_branch_actions::{BranchListing, BranchListingFilter};
use gitbutler_command_context::CommandContext;
use gitbutler_stack::BranchIdentity;
/// A flattened and simplified mirror of `BranchListing` for comparing the actual and expected data.
#[derive(Debug, PartialEq)]

View File

@ -90,9 +90,9 @@ fn many_commits_in_all_branch_types() -> anyhow::Result<()> {
}
mod util {
use gitbutler_branch::BranchIdentity;
use gitbutler_branch_actions::{Author, BranchListingDetails};
use gitbutler_command_context::CommandContext;
use gitbutler_stack::BranchIdentity;
pub fn branch_details(
ctx: &CommandContext,

View File

@ -1,12 +1,12 @@
use std::{fs, path, path::PathBuf, str::FromStr};
use gitbutler_branch::{BranchCreateRequest, VirtualBranchesHandle};
use gitbutler_branch_actions::update_workspace_commit;
use gitbutler_branch_actions::GITBUTLER_WORKSPACE_COMMIT_TITLE;
use gitbutler_command_context::CommandContext;
use gitbutler_error::error::Marker;
use gitbutler_project::{self as projects, Project, ProjectId};
use gitbutler_reference::Refname;
use gitbutler_stack::{BranchCreateRequest, VirtualBranchesHandle};
use gitbutler_testsupport::{paths, TestProject, VAR_NO_CLEANUP};
use tempfile::TempDir;

View File

@ -1,5 +1,5 @@
use gitbutler_branch::{BranchCreateRequest, BranchOwnershipClaims};
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_stack::{BranchCreateRequest, BranchOwnershipClaims};
use super::*;

View File

@ -1,5 +1,5 @@
use bstr::ByteSlice;
use gitbutler_branch::{BranchCreateRequest, BranchId};
use gitbutler_stack::{BranchCreateRequest, BranchId};
use std::{path::PathBuf, str::FromStr};
use super::Test;

View File

@ -1,7 +1,7 @@
use std::{io::Write, path::Path, time::Duration};
use gitbutler_branch::{BranchCreateRequest, VirtualBranchesHandle};
use gitbutler_oplog::OplogExt;
use gitbutler_stack::{BranchCreateRequest, VirtualBranchesHandle};
use itertools::Itertools;
use super::*;

View File

@ -1,7 +1,7 @@
use super::*;
mod create_virtual_branch {
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::*;
@ -90,7 +90,7 @@ mod create_virtual_branch {
}
mod update_virtual_branch {
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
use gitbutler_stack::{BranchCreateRequest, BranchUpdateRequest};
use super::*;
@ -202,7 +202,7 @@ mod update_virtual_branch {
}
mod push_virtual_branch {
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
use gitbutler_stack::{BranchCreateRequest, BranchUpdateRequest};
use super::*;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::*;

View File

@ -1,6 +1,6 @@
use std::fs;
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::Test;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
use gitbutler_stack::{BranchCreateRequest, BranchUpdateRequest};
use super::*;

View File

@ -33,7 +33,7 @@ mod error {
}
mod go_back_to_workspace {
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use pretty_assertions::assert_eq;
use super::*;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
use gitbutler_stack::{BranchCreateRequest, BranchUpdateRequest};
use super::*;

View File

@ -1,6 +1,6 @@
use std::fs;
use gitbutler_branch::{BranchCreateRequest, BranchOwnershipClaims};
use gitbutler_stack::{BranchCreateRequest, BranchOwnershipClaims};
use super::Test;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::*;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::*;

View File

@ -1,7 +1,7 @@
use super::*;
mod applied_branch {
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::*;
@ -392,7 +392,7 @@ mod applied_branch {
}
mod no_conflicts_pushed {
use gitbutler_branch::BranchUpdateRequest;
use gitbutler_stack::BranchUpdateRequest;
use super::*;

View File

@ -1,5 +1,5 @@
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_stack::{BranchCreateRequest, BranchUpdateRequest};
use super::*;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_stack::BranchCreateRequest;
use super::*;

View File

@ -1,8 +1,8 @@
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch_actions::update_workspace_commit;
use gitbutler_operating_modes::{
assure_open_workspace_mode, INTEGRATION_BRANCH_REF, WORKSPACE_BRANCH_REF,
};
use gitbutler_stack::VirtualBranchesHandle;
/// Tests that "verify branch" won't complain if we are on the old integration
/// branch, and that `update_workspace_commit` will put us back on the a branch

View File

@ -18,6 +18,7 @@ gitbutler-diff.workspace = true
gitbutler-oxidize.workspace = true
gitbutler-patch-reference.workspace = true
gitbutler-time.workspace = true
gitbutler-stack.workspace = true
itertools = "0.13"
toml.workspace = true
serde = { workspace = true, features = ["std"] }

View File

@ -1,26 +1,15 @@
mod branch;
pub use branch::{Branch, BranchCreateRequest, BranchId, BranchIdentity, BranchUpdateRequest};
mod branch_ext;
pub use branch_ext::BranchExt;
mod reference_ext;
pub use reference_ext::{ReferenceExt, ReferenceExtGix};
mod dedup;
pub use dedup::{dedup, dedup_fmt};
mod file_ownership;
pub use file_ownership::OwnershipClaim;
mod ownership;
pub use ownership::{reconcile_claims, BranchOwnershipClaims, ClaimOutcome};
pub mod serde;
mod target;
pub use target::Target;
mod reference;
pub mod serde;
pub use reference::ChangeReference;
mod state;
use gitbutler_oxidize::gix_to_git2_signature;
use lazy_static::lazy_static;
pub use state::{VirtualBranches as VirtualBranchesState, VirtualBranchesHandle};
lazy_static! {
pub static ref GITBUTLER_WORKSPACE_REFERENCE: gitbutler_reference::LocalRefname =
gitbutler_reference::LocalRefname::new("gitbutler/workspace", None);

View File

@ -1,7 +1,7 @@
use gitbutler_reference::ReferenceName;
use serde::{Deserialize, Serialize};
use crate::BranchId;
use gitbutler_stack::BranchId;
/// GitButler reference associated with a change (commit) on a virtual branch.
/// These are not the same as regular Git references, but rather app-managed refs.

View File

@ -1,6 +1,6 @@
use crate::BranchIdentity;
use anyhow::{Context, Result};
use bstr::{BStr, ByteSlice};
use gitbutler_stack::BranchIdentity;
use gix::refs::Category;
use itertools::Itertools;
use std::borrow::Cow;

View File

@ -1,2 +1 @@
pub mod file_ownership;
pub mod ownership;

View File

@ -18,6 +18,7 @@ gitbutler-branch-actions.workspace = true
gitbutler-command-context.workspace = true
gitbutler-branch.workspace = true
gitbutler-diff.workspace = true
gitbutler-stack.workspace = true
gix = { workspace = true, features = ["max-performance", "tracing"] }
dirs-next = "2.0.0"
clap = { version = "4.5.19", features = ["derive", "env"] }

View File

@ -28,7 +28,7 @@ pub enum Subcommands {
}
pub mod vbranch {
use gitbutler_branch::BranchIdentity;
use gitbutler_stack::BranchIdentity;
#[derive(Debug, clap::Parser)]
pub struct Platform {

View File

@ -1,10 +1,10 @@
use anyhow::{bail, Result};
use gitbutler_branch::{
Branch, BranchCreateRequest, BranchIdentity, BranchUpdateRequest, VirtualBranchesHandle,
};
use gitbutler_branch_actions::{get_branch_listing_details, list_branches};
use gitbutler_command_context::CommandContext;
use gitbutler_project::Project;
use gitbutler_stack::{
Branch, BranchCreateRequest, BranchIdentity, BranchUpdateRequest, VirtualBranchesHandle,
};
use crate::command::debug_print;

View File

@ -20,5 +20,6 @@ gitbutler-reference.workspace = true
gitbutler-time.workspace = true
gitbutler-oplog.workspace = true
gitbutler-diff.workspace = true
gitbutler-stack.workspace = true
gitbutler-cherry-pick.workspace = true
serde.workspace = true

View File

@ -3,7 +3,7 @@ use std::str::FromStr;
use anyhow::{bail, Context, Result};
use bstr::ByteSlice;
use git2::build::CheckoutBuilder;
use gitbutler_branch::{signature, Branch, SignaturePurpose, VirtualBranchesHandle};
use gitbutler_branch::{signature, SignaturePurpose};
use gitbutler_branch_actions::branch_trees::{
checkout_branch_trees, compute_updated_branch_head, BranchHeadAndTree,
};
@ -23,6 +23,7 @@ use gitbutler_operating_modes::{
use gitbutler_project::access::{WorktreeReadPermission, WorktreeWritePermission};
use gitbutler_reference::{ReferenceName, Refname};
use gitbutler_repo::{rebase::cherry_rebase, RepositoryExt};
use gitbutler_stack::{Branch, VirtualBranchesHandle};
pub mod commands;

View File

@ -22,6 +22,7 @@ gitbutler-serde.workspace = true
gitbutler-fs.workspace = true
gitbutler-reference.workspace = true
gitbutler-diff.workspace = true
gitbutler-stack.workspace = true
[[test]]
name = "oplog"

View File

@ -8,7 +8,7 @@ use std::{
use anyhow::{anyhow, bail, Context, Result};
use git2::{DiffOptions, FileMode};
use gitbutler_branch::{Branch, SignaturePurpose, VirtualBranchesHandle, VirtualBranchesState};
use gitbutler_branch::SignaturePurpose;
use gitbutler_command_context::RepositoryExtLite;
use gitbutler_diff::{hunks_by_filepath, FileDiff};
use gitbutler_project::{
@ -16,6 +16,7 @@ use gitbutler_project::{
Project,
};
use gitbutler_repo::RepositoryExt;
use gitbutler_stack::{Branch, VirtualBranchesHandle, VirtualBranchesState};
use tracing::instrument;
use super::{

View File

@ -1,9 +1,9 @@
use std::vec;
use anyhow::Result;
use gitbutler_branch::{Branch, BranchUpdateRequest};
use gitbutler_project::{access::WorktreeWritePermission, Project};
use gitbutler_reference::ReferenceName;
use gitbutler_stack::{Branch, BranchUpdateRequest};
use super::entry::Trailer;
use crate::{

View File

@ -36,6 +36,7 @@ gitbutler-commit.workspace = true
gitbutler-url.workspace = true
gitbutler-cherry-pick.workspace = true
gitbutler-oxidize.workspace = true
gitbutler-stack.workspace = true
uuid.workspace = true
itertools = "0.13"

View File

@ -1,7 +1,7 @@
use std::{collections::HashMap, path::Path, sync::Arc};
use gitbutler_branch::BranchId;
use gitbutler_id::id::Id;
use gitbutler_stack::BranchId;
use serde::Serialize;
use tokio::sync::{oneshot, Mutex};

View File

@ -1,12 +1,12 @@
use std::str::FromStr;
use anyhow::{anyhow, Context, Result};
use gitbutler_branch::{Branch, BranchId};
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_headers::CommitHeadersV2;
use gitbutler_error::error::Code;
use gitbutler_project::AuthKey;
use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_stack::{Branch, BranchId};
use crate::{askpass, credentials, RepositoryExt};
pub trait RepoActionsExt {

View File

@ -18,6 +18,7 @@ gitbutler-patch-reference.workspace = true
gitbutler-reference.workspace = true
gitbutler-repo.workspace = true
gitbutler-commit.workspace = true
gitbutler-stack.workspace = true
[[test]]
name = "stack-api"

View File

@ -4,9 +4,6 @@ use anyhow::anyhow;
use anyhow::bail;
use anyhow::Context;
use anyhow::Result;
use gitbutler_branch::Branch;
use gitbutler_branch::Target;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
@ -15,6 +12,9 @@ use gitbutler_reference::RemoteRefname;
use gitbutler_repo::LogUntil;
use gitbutler_repo::RepoActionsExt;
use gitbutler_repo::RepositoryExt;
use gitbutler_stack::Branch;
use gitbutler_stack::Target;
use gitbutler_stack::VirtualBranchesHandle;
use gix::validate::reference::name_partial;
use itertools::Itertools;
use serde::{Deserialize, Serialize};

View File

@ -1,9 +1,9 @@
use anyhow::Result;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_command_context::CommandContext;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
use gitbutler_repo::{LogUntil, RepositoryExt as _};
use gitbutler_stack::VirtualBranchesHandle;
use gitbutler_stack_api::{PatchReferenceUpdate, Stack, TargetUpdate};
use itertools::Itertools;
use tempfile::TempDir;
@ -788,12 +788,12 @@ fn test_ctx(ctx: &CommandContext) -> Result<TestContext> {
})
}
struct TestContext<'a> {
branch: gitbutler_branch::Branch,
branch: gitbutler_stack::Branch,
/// Oldest commit first
commits: Vec<git2::Commit<'a>>,
/// Oldest commit first
#[allow(dead_code)]
other_commits: Vec<git2::Commit<'a>>,
handle: VirtualBranchesHandle,
default_target: gitbutler_branch::Target,
default_target: gitbutler_stack::Target,
}

View File

@ -0,0 +1,27 @@
[package]
name = "gitbutler-stack"
version = "0.0.0"
edition = "2021"
authors = ["GitButler <gitbutler@gitbutler.com>"]
publish = false
[dependencies]
git2.workspace = true
gix = { workspace = true, features = [] }
itertools = "0.13"
anyhow = "1.0.86"
serde = { workspace = true, features = ["std"] }
bstr.workspace = true
toml.workspace = true
gitbutler-patch-reference.workspace = true
gitbutler-reference.workspace = true
gitbutler-id.workspace = true
gitbutler-serde.workspace = true
gitbutler-time.workspace = true
gitbutler-diff.workspace = true
gitbutler-error.workspace = true
gitbutler-fs.workspace = true
[[test]]
name = "branch"
path = "tests/mod.rs"

View File

@ -0,0 +1,11 @@
mod branch;
mod file_ownership;
mod ownership;
mod state;
mod target;
pub use branch::{Branch, BranchCreateRequest, BranchId, BranchIdentity, BranchUpdateRequest};
pub use file_ownership::OwnershipClaim;
pub use ownership::{reconcile_claims, BranchOwnershipClaims, ClaimOutcome};
pub use state::{VirtualBranches as VirtualBranchesState, VirtualBranchesHandle};
pub use target::Target;

View File

@ -1,4 +1,4 @@
use gitbutler_branch::OwnershipClaim;
use gitbutler_stack::OwnershipClaim;
#[test]
fn parse_ownership() {

View File

@ -0,0 +1,2 @@
pub mod file_ownership;
pub mod ownership;

View File

@ -1,7 +1,7 @@
use std::{path::PathBuf, vec};
use gitbutler_branch::{reconcile_claims, Branch, BranchOwnershipClaims, OwnershipClaim};
use gitbutler_diff::Hunk;
use gitbutler_stack::{reconcile_claims, Branch, BranchOwnershipClaims, OwnershipClaim};
#[test]
fn reconcile_ownership_simple() {

View File

@ -19,3 +19,4 @@ gitbutler-reference.workspace = true
gitbutler-error.workspace = true
gitbutler-id.workspace = true
gitbutler-url.workspace = true
gitbutler-stack.workspace = true

View File

@ -4,7 +4,6 @@ use std::{
};
use anyhow::{anyhow, Context, Result};
use gitbutler_branch::{Target, VirtualBranchesHandle};
use gitbutler_command_context::CommandContext;
use gitbutler_error::error::Code;
use gitbutler_id::id::Id;
@ -12,6 +11,7 @@ use gitbutler_oplog::OplogExt;
use gitbutler_project as projects;
use gitbutler_project::{CodePushState, Project};
use gitbutler_reference::Refname;
use gitbutler_stack::{Target, VirtualBranchesHandle};
use gitbutler_url::Url;
use gitbutler_user as users;
use itertools::Itertools;

View File

@ -68,6 +68,7 @@ gitbutler-error.workspace = true
gitbutler-secret.workspace = true
gitbutler-id.workspace = true
gitbutler-storage.workspace = true
gitbutler-stack.workspace = true
gitbutler-diff.workspace = true
gitbutler-operating-modes.workspace = true
gitbutler-edit-mode.workspace = true

View File

@ -1,13 +1,13 @@
use std::path::PathBuf;
use anyhow::{Context, Result};
use gitbutler_branch::BranchId;
use gitbutler_branch_actions::conflicts;
use gitbutler_command_context::CommandContext;
use gitbutler_project as projects;
use gitbutler_project::ProjectId;
use gitbutler_reference::RemoteRefname;
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
use gitbutler_stack::BranchId;
#[derive(Clone)]
pub struct App {

View File

@ -1,7 +1,7 @@
use gitbutler_branch::BranchId;
use gitbutler_branch_actions::stack::CreateSeriesRequest;
use gitbutler_project as projects;
use gitbutler_project::ProjectId;
use gitbutler_stack::BranchId;
use tauri::State;
use tracing::instrument;

View File

@ -1,8 +1,5 @@
pub mod commands {
use anyhow::{anyhow, Context};
use gitbutler_branch::{
BranchCreateRequest, BranchId, BranchOwnershipClaims, BranchUpdateRequest,
};
use gitbutler_branch_actions::internal::PushResult;
use gitbutler_branch_actions::upstream_integration::{
BaseBranchResolution, BaseBranchResolutionApproach, BranchStatuses, Resolution,
@ -17,6 +14,9 @@ pub mod commands {
use gitbutler_reference::{
normalize_branch_name as normalize_name, ReferenceName, Refname, RemoteRefname,
};
use gitbutler_stack::{
BranchCreateRequest, BranchId, BranchOwnershipClaims, BranchUpdateRequest,
};
use std::path::PathBuf;
use tauri::State;
use tracing::instrument;

View File

@ -28,5 +28,6 @@ gitbutler-branch.workspace = true
gitbutler-reference.workspace = true
gitbutler-storage.workspace = true
gitbutler-url.workspace = true
gitbutler-stack.workspace = true
gitbutler-oxidize.workspace = true
uuid.workspace = true

View File

@ -20,8 +20,8 @@ pub mod paths {
}
pub mod virtual_branches {
use gitbutler_branch::{Target, VirtualBranchesHandle};
use gitbutler_command_context::CommandContext;
use gitbutler_stack::{Target, VirtualBranchesHandle};
use crate::empty_bare_repository;