mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-29 12:33:49 +03:00
Rename Branch to Stack
This commit is contained in:
parent
9e9f3255a8
commit
d05d962cf8
@ -26,13 +26,13 @@ use gitbutler_oplog::{
|
|||||||
use gitbutler_project::{FetchResult, Project};
|
use gitbutler_project::{FetchResult, Project};
|
||||||
use gitbutler_reference::{ReferenceName, Refname, RemoteRefname};
|
use gitbutler_reference::{ReferenceName, Refname, RemoteRefname};
|
||||||
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
||||||
use gitbutler_stack::{BranchId, BranchOwnershipClaims};
|
use gitbutler_stack::{BranchOwnershipClaims, StackId};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
pub fn create_commit(
|
pub fn create_commit(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
message: &str,
|
message: &str,
|
||||||
ownership: Option<&BranchOwnershipClaims>,
|
ownership: Option<&BranchOwnershipClaims>,
|
||||||
run_hooks: bool,
|
run_hooks: bool,
|
||||||
@ -91,7 +91,7 @@ pub fn list_virtual_branches_cached(
|
|||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_virtual_branch(project: &Project, create: &BranchCreateRequest) -> Result<BranchId> {
|
pub fn create_virtual_branch(project: &Project, create: &BranchCreateRequest) -> Result<StackId> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx).context("Creating a branch requires open workspace mode")?;
|
assure_open_workspace_mode(&ctx).context("Creating a branch requires open workspace mode")?;
|
||||||
let mut guard = project.exclusive_worktree_access();
|
let mut guard = project.exclusive_worktree_access();
|
||||||
@ -168,7 +168,7 @@ pub fn push_base_branch(project: &Project, with_force: bool) -> Result<()> {
|
|||||||
base::push(&ctx, with_force)
|
base::push(&ctx, with_force)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn integrate_upstream_commits(project: &Project, branch_id: BranchId) -> Result<()> {
|
pub fn integrate_upstream_commits(project: &Project, branch_id: StackId) -> Result<()> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx)
|
assure_open_workspace_mode(&ctx)
|
||||||
.context("Integrating upstream commits requires open workspace mode")?;
|
.context("Integrating upstream commits requires open workspace mode")?;
|
||||||
@ -234,7 +234,7 @@ pub fn update_branch_order(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unapply_without_saving_virtual_branch(project: &Project, branch_id: BranchId) -> Result<()> {
|
pub fn unapply_without_saving_virtual_branch(project: &Project, branch_id: StackId) -> Result<()> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx)
|
assure_open_workspace_mode(&ctx)
|
||||||
.context("Deleting a branch order requires open workspace mode")?;
|
.context("Deleting a branch order requires open workspace mode")?;
|
||||||
@ -256,7 +256,7 @@ pub fn unapply_ownership(project: &Project, ownership: &BranchOwnershipClaims) -
|
|||||||
vbranch::unapply_ownership(&ctx, ownership, guard.write_permission()).map_err(Into::into)
|
vbranch::unapply_ownership(&ctx, ownership, guard.write_permission()).map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_files(project: &Project, branch_id: BranchId, files: &[PathBuf]) -> Result<()> {
|
pub fn reset_files(project: &Project, branch_id: StackId, files: &[PathBuf]) -> Result<()> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx).context("Resetting a file requires open workspace mode")?;
|
assure_open_workspace_mode(&ctx).context("Resetting a file requires open workspace mode")?;
|
||||||
let mut guard = project.exclusive_worktree_access();
|
let mut guard = project.exclusive_worktree_access();
|
||||||
@ -269,7 +269,7 @@ pub fn reset_files(project: &Project, branch_id: BranchId, files: &[PathBuf]) ->
|
|||||||
|
|
||||||
pub fn amend(
|
pub fn amend(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
ownership: &BranchOwnershipClaims,
|
ownership: &BranchOwnershipClaims,
|
||||||
) -> Result<git2::Oid> {
|
) -> Result<git2::Oid> {
|
||||||
@ -285,7 +285,7 @@ pub fn amend(
|
|||||||
|
|
||||||
pub fn move_commit_file(
|
pub fn move_commit_file(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
from_commit_oid: git2::Oid,
|
from_commit_oid: git2::Oid,
|
||||||
to_commit_oid: git2::Oid,
|
to_commit_oid: git2::Oid,
|
||||||
ownership: &BranchOwnershipClaims,
|
ownership: &BranchOwnershipClaims,
|
||||||
@ -301,7 +301,7 @@ pub fn move_commit_file(
|
|||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn undo_commit(project: &Project, branch_id: BranchId, commit_oid: git2::Oid) -> Result<()> {
|
pub fn undo_commit(project: &Project, branch_id: StackId, commit_oid: git2::Oid) -> Result<()> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx).context("Undoing a commit requires open workspace mode")?;
|
assure_open_workspace_mode(&ctx).context("Undoing a commit requires open workspace mode")?;
|
||||||
let mut guard = project.exclusive_worktree_access();
|
let mut guard = project.exclusive_worktree_access();
|
||||||
@ -322,7 +322,7 @@ pub fn undo_commit(project: &Project, branch_id: BranchId, commit_oid: git2::Oid
|
|||||||
|
|
||||||
pub fn insert_blank_commit(
|
pub fn insert_blank_commit(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
offset: i32,
|
offset: i32,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -339,7 +339,7 @@ pub fn insert_blank_commit(
|
|||||||
|
|
||||||
pub fn reorder_commit(
|
pub fn reorder_commit(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
offset: i32,
|
offset: i32,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -362,7 +362,7 @@ pub fn reorder_commit(
|
|||||||
|
|
||||||
pub fn reset_virtual_branch(
|
pub fn reset_virtual_branch(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
target_commit_oid: git2::Oid,
|
target_commit_oid: git2::Oid,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
@ -377,7 +377,7 @@ pub fn reset_virtual_branch(
|
|||||||
|
|
||||||
pub fn save_and_unapply_virutal_branch(
|
pub fn save_and_unapply_virutal_branch(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
) -> Result<ReferenceName> {
|
) -> Result<ReferenceName> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx)
|
assure_open_workspace_mode(&ctx)
|
||||||
@ -400,9 +400,9 @@ pub fn save_and_unapply_virutal_branch(
|
|||||||
|
|
||||||
pub fn push_virtual_branch(
|
pub fn push_virtual_branch(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
askpass: Option<Option<BranchId>>,
|
askpass: Option<Option<StackId>>,
|
||||||
) -> Result<vbranch::PushResult> {
|
) -> Result<vbranch::PushResult> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx).context("Pushing a branch requires open workspace mode")?;
|
assure_open_workspace_mode(&ctx).context("Pushing a branch requires open workspace mode")?;
|
||||||
@ -419,7 +419,7 @@ pub fn get_remote_branch_data(project: &Project, refname: &Refname) -> Result<Re
|
|||||||
remote::get_branch_data(&ctx, refname)
|
remote::get_branch_data(&ctx, refname)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn squash(project: &Project, branch_id: BranchId, commit_oid: git2::Oid) -> Result<()> {
|
pub fn squash(project: &Project, branch_id: StackId, commit_oid: git2::Oid) -> Result<()> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx).context("Squashing a commit requires open workspace mode")?;
|
assure_open_workspace_mode(&ctx).context("Squashing a commit requires open workspace mode")?;
|
||||||
let mut guard = project.exclusive_worktree_access();
|
let mut guard = project.exclusive_worktree_access();
|
||||||
@ -432,7 +432,7 @@ pub fn squash(project: &Project, branch_id: BranchId, commit_oid: git2::Oid) ->
|
|||||||
|
|
||||||
pub fn update_commit_message(
|
pub fn update_commit_message(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
message: &str,
|
message: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -480,7 +480,7 @@ pub fn fetch_from_remotes(project: &Project, askpass: Option<String>) -> Result<
|
|||||||
|
|
||||||
pub fn move_commit(
|
pub fn move_commit(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
target_branch_id: BranchId,
|
target_branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
@ -499,7 +499,7 @@ pub fn create_virtual_branch_from_branch(
|
|||||||
project: &Project,
|
project: &Project,
|
||||||
branch: &Refname,
|
branch: &Refname,
|
||||||
remote: Option<RemoteRefname>,
|
remote: Option<RemoteRefname>,
|
||||||
) -> Result<BranchId> {
|
) -> Result<StackId> {
|
||||||
let ctx = open_with_verify(project)?;
|
let ctx = open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(&ctx)
|
assure_open_workspace_mode(&ctx)
|
||||||
.context("Creating a virtual branch from a branch open workspace mode")?;
|
.context("Creating a virtual branch from a branch open workspace mode")?;
|
||||||
|
@ -8,7 +8,7 @@ use gitbutler_error::error::Marker;
|
|||||||
use gitbutler_project::{access::WorktreeWritePermission, FetchResult};
|
use gitbutler_project::{access::WorktreeWritePermission, FetchResult};
|
||||||
use gitbutler_reference::{ReferenceName, Refname, RemoteRefname};
|
use gitbutler_reference::{ReferenceName, Refname, RemoteRefname};
|
||||||
use gitbutler_repo::{rebase::cherry_rebase, LogUntil, RepoActionsExt, RepositoryExt};
|
use gitbutler_repo::{rebase::cherry_rebase, LogUntil, RepoActionsExt, RepositoryExt};
|
||||||
use gitbutler_stack::{Branch, BranchOwnershipClaims, Target, VirtualBranchesHandle};
|
use gitbutler_stack::{BranchOwnershipClaims, Stack, Target, VirtualBranchesHandle};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -231,7 +231,7 @@ pub(crate) fn set_base_branch(
|
|||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut branch = Branch::new(
|
let mut branch = Stack::new(
|
||||||
head_name.to_string().replace("refs/heads/", ""),
|
head_name.to_string().replace("refs/heads/", ""),
|
||||||
Some(head_name),
|
Some(head_name),
|
||||||
upstream,
|
upstream,
|
||||||
@ -355,7 +355,7 @@ pub(crate) fn update_base_branch(
|
|||||||
let updated_vbranches = get_applied_status(ctx, None)?
|
let updated_vbranches = get_applied_status(ctx, None)?
|
||||||
.branches
|
.branches
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(mut branch, _)| -> Result<Option<Branch>> {
|
.map(|(mut branch, _)| -> Result<Option<Stack>> {
|
||||||
let branch_tree = repo.find_tree(branch.tree)?;
|
let branch_tree = repo.find_tree(branch.tree)?;
|
||||||
|
|
||||||
let branch_head_commit = repo.find_commit(branch.head()).context(format!(
|
let branch_head_commit = repo.find_commit(branch.head()).context(format!(
|
||||||
@ -369,7 +369,7 @@ pub(crate) fn update_base_branch(
|
|||||||
branch.id
|
branch.id
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
let result_integrated_detected = |mut branch: Branch| -> Result<Option<Branch>> {
|
let result_integrated_detected = |mut branch: Stack| -> Result<Option<Stack>> {
|
||||||
// branch head tree is the same as the new target tree.
|
// branch head tree is the same as the new target tree.
|
||||||
// meaning we can safely use the new target commit as the branch head.
|
// meaning we can safely use the new target commit as the branch head.
|
||||||
|
|
||||||
@ -455,7 +455,7 @@ pub(crate) fn update_base_branch(
|
|||||||
|
|
||||||
let ok_with_force_push = branch.allow_rebasing;
|
let ok_with_force_push = branch.allow_rebasing;
|
||||||
|
|
||||||
let result_merge = |mut branch: Branch| -> Result<Option<Branch>> {
|
let result_merge = |mut branch: Stack| -> Result<Option<Stack>> {
|
||||||
// branch was pushed to upstream, and user doesn't like force pushing.
|
// branch was pushed to upstream, and user doesn't like force pushing.
|
||||||
// create a merge commit to avoid the need of force pushing then.
|
// create a merge commit to avoid the need of force pushing then.
|
||||||
let branch_head_merge_tree = repo
|
let branch_head_merge_tree = repo
|
||||||
|
@ -11,7 +11,7 @@ use gitbutler_project::access::WorktreeReadPermission;
|
|||||||
use gitbutler_reference::normalize_branch_name;
|
use gitbutler_reference::normalize_branch_name;
|
||||||
use gitbutler_repo::{GixRepositoryExt, RepositoryExt as _};
|
use gitbutler_repo::{GixRepositoryExt, RepositoryExt as _};
|
||||||
use gitbutler_serde::BStringForFrontend;
|
use gitbutler_serde::BStringForFrontend;
|
||||||
use gitbutler_stack::{Branch as GitButlerBranch, BranchId, Target};
|
use gitbutler_stack::{Stack as GitButlerBranch, StackId, Target};
|
||||||
use gix::object::tree::diff::Action;
|
use gix::object::tree::diff::Action;
|
||||||
use gix::prelude::ObjectIdExt;
|
use gix::prelude::ObjectIdExt;
|
||||||
use gix::reference::Category;
|
use gix::reference::Category;
|
||||||
@ -437,7 +437,7 @@ pub struct VirtualBranchReference {
|
|||||||
/// A non-normalized name of the branch, set by the user
|
/// A non-normalized name of the branch, set by the user
|
||||||
pub given_name: String,
|
pub given_name: String,
|
||||||
/// Virtual Branch UUID identifier
|
/// Virtual Branch UUID identifier
|
||||||
pub id: BranchId,
|
pub id: StackId,
|
||||||
/// Determines if the virtual branch is applied in the workspace
|
/// Determines if the virtual branch is applied in the workspace
|
||||||
pub in_workspace: bool,
|
pub in_workspace: bool,
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ use gitbutler_repo::{
|
|||||||
rebase::{cherry_rebase_group, gitbutler_merge_commits},
|
rebase::{cherry_rebase_group, gitbutler_merge_commits},
|
||||||
LogUntil, RepoActionsExt, RepositoryExt,
|
LogUntil, RepoActionsExt, RepositoryExt,
|
||||||
};
|
};
|
||||||
use gitbutler_stack::{Branch, BranchId, BranchOwnershipClaims};
|
use gitbutler_stack::{BranchOwnershipClaims, Stack, StackId};
|
||||||
use gitbutler_time::time::now_since_unix_epoch_ms;
|
use gitbutler_time::time::now_since_unix_epoch_ms;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ impl BranchManager<'_> {
|
|||||||
&self,
|
&self,
|
||||||
create: &BranchCreateRequest,
|
create: &BranchCreateRequest,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
) -> Result<Branch> {
|
) -> Result<Stack> {
|
||||||
let vb_state = self.ctx.project().virtual_branches();
|
let vb_state = self.ctx.project().virtual_branches();
|
||||||
let default_target = vb_state.get_default_target()?;
|
let default_target = vb_state.get_default_target()?;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ impl BranchManager<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut branch = Branch::new(
|
let mut branch = Stack::new(
|
||||||
name.clone(),
|
name.clone(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -128,7 +128,7 @@ impl BranchManager<'_> {
|
|||||||
target: &Refname,
|
target: &Refname,
|
||||||
upstream_branch: Option<RemoteRefname>,
|
upstream_branch: Option<RemoteRefname>,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
) -> Result<BranchId> {
|
) -> Result<StackId> {
|
||||||
// only set upstream if it's not the default target
|
// only set upstream if it's not the default target
|
||||||
let upstream_branch = match upstream_branch {
|
let upstream_branch = match upstream_branch {
|
||||||
Some(upstream_branch) => Some(upstream_branch),
|
Some(upstream_branch) => Some(upstream_branch),
|
||||||
@ -182,7 +182,7 @@ impl BranchManager<'_> {
|
|||||||
.list_branches_in_workspace()
|
.list_branches_in_workspace()
|
||||||
.context("failed to read virtual branches")?
|
.context("failed to read virtual branches")?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<Vec<Branch>>();
|
.collect::<Vec<Stack>>();
|
||||||
|
|
||||||
let order = vb_state.next_order_index()?;
|
let order = vb_state.next_order_index()?;
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ impl BranchManager<'_> {
|
|||||||
branch
|
branch
|
||||||
} else {
|
} else {
|
||||||
let upstream_head = upstream_branch.is_some().then_some(head_commit.id());
|
let upstream_head = upstream_branch.is_some().then_some(head_commit.id());
|
||||||
Branch::new(
|
Stack::new(
|
||||||
branch_name.clone(),
|
branch_name.clone(),
|
||||||
Some(target.clone()),
|
Some(target.clone()),
|
||||||
upstream_branch,
|
upstream_branch,
|
||||||
@ -271,7 +271,7 @@ impl BranchManager<'_> {
|
|||||||
#[instrument(level = tracing::Level::DEBUG, skip(self, perm), err(Debug))]
|
#[instrument(level = tracing::Level::DEBUG, skip(self, perm), err(Debug))]
|
||||||
fn apply_branch(
|
fn apply_branch(
|
||||||
&self,
|
&self,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
self.ctx.assure_resolved()?;
|
self.ctx.assure_resolved()?;
|
||||||
|
@ -8,7 +8,7 @@ use gitbutler_oplog::SnapshotExt;
|
|||||||
use gitbutler_project::access::WorktreeWritePermission;
|
use gitbutler_project::access::WorktreeWritePermission;
|
||||||
use gitbutler_reference::{normalize_branch_name, ReferenceName, Refname};
|
use gitbutler_reference::{normalize_branch_name, ReferenceName, Refname};
|
||||||
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
||||||
use gitbutler_stack::{Branch, BranchId};
|
use gitbutler_stack::{Stack, StackId};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use super::BranchManager;
|
use super::BranchManager;
|
||||||
@ -25,7 +25,7 @@ impl BranchManager<'_> {
|
|||||||
#[instrument(level = tracing::Level::DEBUG, skip(self, perm), err(Debug))]
|
#[instrument(level = tracing::Level::DEBUG, skip(self, perm), err(Debug))]
|
||||||
pub fn save_and_unapply(
|
pub fn save_and_unapply(
|
||||||
&self,
|
&self,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
) -> Result<ReferenceName> {
|
) -> Result<ReferenceName> {
|
||||||
let vb_state = self.ctx.project().virtual_branches();
|
let vb_state = self.ctx.project().virtual_branches();
|
||||||
@ -55,7 +55,7 @@ impl BranchManager<'_> {
|
|||||||
#[instrument(level = tracing::Level::DEBUG, skip(self, perm), err(Debug))]
|
#[instrument(level = tracing::Level::DEBUG, skip(self, perm), err(Debug))]
|
||||||
pub(crate) fn unapply_without_saving(
|
pub(crate) fn unapply_without_saving(
|
||||||
&self,
|
&self,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
target_commit: &Commit,
|
target_commit: &Commit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -146,7 +146,7 @@ impl BranchManager<'_> {
|
|||||||
|
|
||||||
impl BranchManager<'_> {
|
impl BranchManager<'_> {
|
||||||
#[instrument(level = tracing::Level::DEBUG, skip(self, vbranch), err(Debug))]
|
#[instrument(level = tracing::Level::DEBUG, skip(self, vbranch), err(Debug))]
|
||||||
fn build_real_branch(&self, vbranch: &mut Branch) -> Result<git2::Branch<'_>> {
|
fn build_real_branch(&self, vbranch: &mut Stack) -> Result<git2::Branch<'_>> {
|
||||||
let repo = self.ctx.repository();
|
let repo = self.ctx.repository();
|
||||||
let target_commit = repo.find_commit(vbranch.head())?;
|
let target_commit = repo.find_commit(vbranch.head())?;
|
||||||
let branch_name = vbranch.name.clone();
|
let branch_name = vbranch.name.clone();
|
||||||
@ -164,7 +164,7 @@ impl BranchManager<'_> {
|
|||||||
|
|
||||||
fn build_wip_commit(
|
fn build_wip_commit(
|
||||||
&self,
|
&self,
|
||||||
vbranch: &mut Branch,
|
vbranch: &mut Stack,
|
||||||
branch: &git2::Branch<'_>,
|
branch: &git2::Branch<'_>,
|
||||||
) -> Result<Option<git2::Oid>> {
|
) -> Result<Option<git2::Oid>> {
|
||||||
let repo = self.ctx.repository();
|
let repo = self.ctx.repository();
|
||||||
|
@ -5,7 +5,7 @@ use gitbutler_commit::commit_ext::CommitExt as _;
|
|||||||
use gitbutler_project::access::WorktreeWritePermission;
|
use gitbutler_project::access::WorktreeWritePermission;
|
||||||
use gitbutler_repo::rebase::cherry_rebase_group;
|
use gitbutler_repo::rebase::cherry_rebase_group;
|
||||||
use gitbutler_repo::RepositoryExt as _;
|
use gitbutler_repo::RepositoryExt as _;
|
||||||
use gitbutler_stack::Branch;
|
use gitbutler_stack::Stack;
|
||||||
|
|
||||||
use crate::VirtualBranchesExt as _;
|
use crate::VirtualBranchesExt as _;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ pub struct BranchHeadAndTree {
|
|||||||
/// mutated the virtual_branches.toml.
|
/// mutated the virtual_branches.toml.
|
||||||
pub fn compute_updated_branch_head(
|
pub fn compute_updated_branch_head(
|
||||||
repository: &git2::Repository,
|
repository: &git2::Repository,
|
||||||
branch: &Branch,
|
branch: &Stack,
|
||||||
new_head: git2::Oid,
|
new_head: git2::Oid,
|
||||||
fearless_rebasing: bool,
|
fearless_rebasing: bool,
|
||||||
) -> Result<BranchHeadAndTree> {
|
) -> Result<BranchHeadAndTree> {
|
||||||
|
@ -6,7 +6,7 @@ use anyhow::{Context, Result};
|
|||||||
use gitbutler_command_context::CommandContext;
|
use gitbutler_command_context::CommandContext;
|
||||||
use gitbutler_commit::commit_ext::CommitExt;
|
use gitbutler_commit::commit_ext::CommitExt;
|
||||||
use gitbutler_serde::BStringForFrontend;
|
use gitbutler_serde::BStringForFrontend;
|
||||||
use gitbutler_stack::{Branch, BranchId};
|
use gitbutler_stack::{Stack, StackId};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
// this is the struct that maps to the view `Commit` type in Typescript
|
// this is the struct that maps to the view `Commit` type in Typescript
|
||||||
@ -30,7 +30,7 @@ pub struct VirtualBranchCommit {
|
|||||||
pub is_integrated: bool,
|
pub is_integrated: bool,
|
||||||
#[serde(with = "gitbutler_serde::oid_vec")]
|
#[serde(with = "gitbutler_serde::oid_vec")]
|
||||||
pub parent_ids: Vec<git2::Oid>,
|
pub parent_ids: Vec<git2::Oid>,
|
||||||
pub branch_id: BranchId,
|
pub branch_id: StackId,
|
||||||
pub change_id: Option<String>,
|
pub change_id: Option<String>,
|
||||||
pub is_signed: bool,
|
pub is_signed: bool,
|
||||||
pub conflicted: bool,
|
pub conflicted: bool,
|
||||||
@ -43,7 +43,7 @@ pub struct VirtualBranchCommit {
|
|||||||
|
|
||||||
pub(crate) fn commit_to_vbranch_commit(
|
pub(crate) fn commit_to_vbranch_commit(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch: &Branch,
|
branch: &Stack,
|
||||||
commit: &git2::Commit,
|
commit: &git2::Commit,
|
||||||
is_integrated: bool,
|
is_integrated: bool,
|
||||||
is_remote: bool,
|
is_remote: bool,
|
||||||
|
@ -7,7 +7,7 @@ use std::{
|
|||||||
|
|
||||||
use gitbutler_diff::{GitHunk, Hunk, HunkHash};
|
use gitbutler_diff::{GitHunk, Hunk, HunkHash};
|
||||||
use gitbutler_serde::BStringForFrontend;
|
use gitbutler_serde::BStringForFrontend;
|
||||||
use gitbutler_stack::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use md5::Digest;
|
use md5::Digest;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
@ -48,7 +48,7 @@ pub struct VirtualBranchHunk {
|
|||||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Copy)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct HunkLock {
|
pub struct HunkLock {
|
||||||
pub branch_id: BranchId,
|
pub branch_id: StackId,
|
||||||
#[serde(with = "gitbutler_serde::oid")]
|
#[serde(with = "gitbutler_serde::oid")]
|
||||||
pub commit_id: git2::Oid,
|
pub commit_id: git2::Oid,
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use gitbutler_error::error::Marker;
|
|||||||
use gitbutler_operating_modes::OPEN_WORKSPACE_REFS;
|
use gitbutler_operating_modes::OPEN_WORKSPACE_REFS;
|
||||||
use gitbutler_project::access::WorktreeWritePermission;
|
use gitbutler_project::access::WorktreeWritePermission;
|
||||||
use gitbutler_repo::{LogUntil, RepositoryExt};
|
use gitbutler_repo::{LogUntil, RepositoryExt};
|
||||||
use gitbutler_stack::{Branch, VirtualBranchesHandle};
|
use gitbutler_stack::{Stack, VirtualBranchesHandle};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::{branch_manager::BranchManagerExt, conflicts, VirtualBranchesExt};
|
use crate::{branch_manager::BranchManagerExt, conflicts, VirtualBranchesExt};
|
||||||
@ -36,7 +36,7 @@ pub(crate) fn get_workspace_head(ctx: &CommandContext) -> Result<git2::Oid> {
|
|||||||
.context("failed to get target")?;
|
.context("failed to get target")?;
|
||||||
let repo: &git2::Repository = ctx.repository();
|
let repo: &git2::Repository = ctx.repository();
|
||||||
|
|
||||||
let mut virtual_branches: Vec<Branch> = vb_state.list_branches_in_workspace()?;
|
let mut virtual_branches: Vec<Stack> = vb_state.list_branches_in_workspace()?;
|
||||||
|
|
||||||
let target_commit = repo.find_commit(target.sha)?;
|
let target_commit = repo.find_commit(target.sha)?;
|
||||||
let mut workspace_tree = repo.find_real_tree(&target_commit, Default::default())?;
|
let mut workspace_tree = repo.find_real_tree(&target_commit, Default::default())?;
|
||||||
@ -152,7 +152,7 @@ pub fn update_workspace_commit(
|
|||||||
let vb_state = ctx.project().virtual_branches();
|
let vb_state = ctx.project().virtual_branches();
|
||||||
|
|
||||||
// get all virtual branches, we need to try to update them all
|
// get all virtual branches, we need to try to update them all
|
||||||
let virtual_branches: Vec<Branch> = vb_state
|
let virtual_branches: Vec<Stack> = vb_state
|
||||||
.list_branches_in_workspace()
|
.list_branches_in_workspace()
|
||||||
.context("failed to list virtual branches")?;
|
.context("failed to list virtual branches")?;
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ 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::{BranchId, OwnershipClaim};
|
use gitbutler_stack::{OwnershipClaim, StackId};
|
||||||
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
|
||||||
pub(crate) fn move_commit(
|
pub(crate) fn move_commit(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
target_branch_id: BranchId,
|
target_branch_id: StackId,
|
||||||
commit_id: git2::Oid,
|
commit_id: git2::Oid,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
@ -2,7 +2,7 @@ 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::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
branch_trees::{
|
branch_trees::{
|
||||||
@ -38,7 +38,7 @@ use crate::{
|
|||||||
/// D
|
/// D
|
||||||
pub(crate) fn reorder_commit(
|
pub(crate) fn reorder_commit(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
subject_commit_oid: git2::Oid,
|
subject_commit_oid: git2::Oid,
|
||||||
offset: i32,
|
offset: i32,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
|
@ -2,8 +2,8 @@ use anyhow::{Context, Result};
|
|||||||
use gitbutler_commit::commit_ext::CommitExt;
|
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_stack::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
use gitbutler_stack_api::{PatchReferenceUpdate, Stack};
|
use gitbutler_stack_api::{PatchReferenceUpdate, StackActions};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{actions::open_with_verify, VirtualBranchesExt};
|
use crate::{actions::open_with_verify, VirtualBranchesExt};
|
||||||
@ -22,7 +22,7 @@ use gitbutler_operating_modes::assure_open_workspace_mode;
|
|||||||
/// The argument `preceding_head` is only used if there are multiple heads that point to the same patch, otherwise it is ignored.
|
/// The argument `preceding_head` is only used if there are multiple heads that point to the same patch, otherwise it is ignored.
|
||||||
pub fn create_series(
|
pub fn create_series(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
req: CreateSeriesRequest,
|
req: CreateSeriesRequest,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let ctx = &open_with_verify(project)?;
|
let ctx = &open_with_verify(project)?;
|
||||||
@ -62,7 +62,7 @@ pub struct CreateSeriesRequest {
|
|||||||
/// The very last branch (reference) cannot be removed (A Stack must always contains at least one reference)
|
/// The very last branch (reference) cannot be removed (A Stack must always contains at least one reference)
|
||||||
/// If there were commits/changes that were *only* referenced by the removed branch,
|
/// If there were commits/changes that were *only* referenced by the removed branch,
|
||||||
/// those commits are moved to the branch underneath it (or more accurately, the precee)
|
/// those commits are moved to the branch underneath it (or more accurately, the precee)
|
||||||
pub fn remove_series(project: &Project, branch_id: BranchId, head_name: String) -> Result<()> {
|
pub fn remove_series(project: &Project, branch_id: StackId, head_name: String) -> Result<()> {
|
||||||
let ctx = &open_with_verify(project)?;
|
let ctx = &open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(ctx).context("Requires an open workspace mode")?;
|
assure_open_workspace_mode(ctx).context("Requires an open workspace mode")?;
|
||||||
let mut stack = ctx.project().virtual_branches().get_branch(branch_id)?;
|
let mut stack = ctx.project().virtual_branches().get_branch(branch_id)?;
|
||||||
@ -74,7 +74,7 @@ pub fn remove_series(project: &Project, branch_id: BranchId, head_name: String)
|
|||||||
/// If the series have been pushed to a remote, the name can not be changed as it corresponds to a remote ref.
|
/// If the series have been pushed to a remote, the name can not be changed as it corresponds to a remote ref.
|
||||||
pub fn update_series_name(
|
pub fn update_series_name(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
head_name: String,
|
head_name: String,
|
||||||
new_head_name: String,
|
new_head_name: String,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -95,7 +95,7 @@ pub fn update_series_name(
|
|||||||
/// The description can be set to `None` to remove it.
|
/// The description can be set to `None` to remove it.
|
||||||
pub fn update_series_description(
|
pub fn update_series_description(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
head_name: String,
|
head_name: String,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -114,7 +114,7 @@ pub fn update_series_description(
|
|||||||
|
|
||||||
/// Pushes all series in the stack to the remote.
|
/// Pushes all series in the stack to the remote.
|
||||||
/// This operation will error out if the target has no push remote configured.
|
/// This operation will error out if the target has no push remote configured.
|
||||||
pub fn push_stack(project: &Project, branch_id: BranchId, with_force: bool) -> Result<()> {
|
pub fn push_stack(project: &Project, branch_id: StackId, with_force: bool) -> Result<()> {
|
||||||
let ctx = &open_with_verify(project)?;
|
let ctx = &open_with_verify(project)?;
|
||||||
assure_open_workspace_mode(ctx).context("Requires an open workspace mode")?;
|
assure_open_workspace_mode(ctx).context("Requires an open workspace mode")?;
|
||||||
let state = ctx.project().virtual_branches();
|
let state = ctx.project().virtual_branches();
|
||||||
|
@ -15,15 +15,15 @@ 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::{Branch, BranchId, BranchOwnershipClaims, OwnershipClaim};
|
use gitbutler_stack::{BranchOwnershipClaims, OwnershipClaim, Stack, StackId};
|
||||||
use gitbutler_stack_api::Stack;
|
use gitbutler_stack_api::StackActions;
|
||||||
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.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VirtualBranchesStatus {
|
pub struct VirtualBranchesStatus {
|
||||||
/// A collection of branches and their associated uncommitted file changes.
|
/// A collection of branches and their associated uncommitted file changes.
|
||||||
pub branches: Vec<(Branch, Vec<VirtualBranchFile>)>,
|
pub branches: Vec<(Stack, Vec<VirtualBranchFile>)>,
|
||||||
/// A collection of files that were skipped during the diffing process (due to being very large and unprocessable).
|
/// A collection of files that were skipped during the diffing process (due to being very large and unprocessable).
|
||||||
pub skipped_files: Vec<gitbutler_diff::FileDiff>,
|
pub skipped_files: Vec<gitbutler_diff::FileDiff>,
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ pub fn get_applied_status_cached(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut diffs_by_branch: HashMap<BranchId, HashMap<PathBuf, Vec<gitbutler_diff::GitHunk>>> =
|
let mut diffs_by_branch: HashMap<StackId, HashMap<PathBuf, Vec<gitbutler_diff::GitHunk>>> =
|
||||||
virtual_branches
|
virtual_branches
|
||||||
.iter()
|
.iter()
|
||||||
.map(|branch| (branch.id, HashMap::new()))
|
.map(|branch| (branch.id, HashMap::new()))
|
||||||
@ -223,7 +223,7 @@ pub fn get_applied_status_cached(
|
|||||||
.context(format!("failed to write virtual branch {}", vbranch.name))?;
|
.context(format!("failed to write virtual branch {}", vbranch.name))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let hunks_by_branch: Vec<(Branch, HashMap<PathBuf, Vec<VirtualBranchHunk>>)> = hunks_by_branch
|
let hunks_by_branch: Vec<(Stack, HashMap<PathBuf, Vec<VirtualBranchHunk>>)> = hunks_by_branch
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(branch, hunks)| {
|
.map(|(branch, hunks)| {
|
||||||
let hunks = file_hunks_from_diffs(&ctx.project().path, hunks.clone(), Some(&locks));
|
let hunks = file_hunks_from_diffs(&ctx.project().path, hunks.clone(), Some(&locks));
|
||||||
@ -231,7 +231,7 @@ pub fn get_applied_status_cached(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let files_by_branch: Vec<(Branch, Vec<VirtualBranchFile>)> = hunks_by_branch
|
let files_by_branch: Vec<(Stack, Vec<VirtualBranchFile>)> = hunks_by_branch
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(branch, hunks)| {
|
.map(|(branch, hunks)| {
|
||||||
let files = virtual_hunks_into_virtual_files(ctx, hunks.clone());
|
let files = virtual_hunks_into_virtual_files(ctx, hunks.clone());
|
||||||
@ -248,7 +248,7 @@ pub fn get_applied_status_cached(
|
|||||||
fn compute_locks(
|
fn compute_locks(
|
||||||
repository: &git2::Repository,
|
repository: &git2::Repository,
|
||||||
unstaged_hunks_by_path: &HashMap<PathBuf, Vec<gitbutler_diff::GitHunk>>,
|
unstaged_hunks_by_path: &HashMap<PathBuf, Vec<gitbutler_diff::GitHunk>>,
|
||||||
virtual_branches: &[Branch],
|
virtual_branches: &[Stack],
|
||||||
base_tree: Tree,
|
base_tree: Tree,
|
||||||
) -> Result<HashMap<HunkHash, Vec<HunkLock>>> {
|
) -> Result<HashMap<HunkHash, Vec<HunkLock>>> {
|
||||||
let mut diff_opts = git2::DiffOptions::new();
|
let mut diff_opts = git2::DiffOptions::new();
|
||||||
@ -275,7 +275,7 @@ fn compute_locks(
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let mut workspace_hunks_by_path =
|
let mut workspace_hunks_by_path =
|
||||||
HashMap::<PathBuf, Vec<(gitbutler_diff::GitHunk, &Branch)>>::new();
|
HashMap::<PathBuf, Vec<(gitbutler_diff::GitHunk, &Stack)>>::new();
|
||||||
|
|
||||||
for (branch, hunks_by_filepath) in branch_path_diffs {
|
for (branch, hunks_by_filepath) in branch_path_diffs {
|
||||||
for (path, hunks) in hunks_by_filepath {
|
for (path, hunks) in hunks_by_filepath {
|
||||||
|
@ -2,7 +2,7 @@ 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::{Branch, BranchId};
|
use gitbutler_stack::{Stack, StackId};
|
||||||
|
|
||||||
use crate::VirtualBranchesExt as _;
|
use crate::VirtualBranchesExt as _;
|
||||||
|
|
||||||
@ -19,9 +19,9 @@ use crate::VirtualBranchesExt as _;
|
|||||||
/// undone.
|
/// undone.
|
||||||
pub(crate) fn undo_commit(
|
pub(crate) fn undo_commit(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
) -> Result<Branch> {
|
) -> Result<Stack> {
|
||||||
let vb_state = ctx.project().virtual_branches();
|
let vb_state = ctx.project().virtual_branches();
|
||||||
let succeeding_rebases = ctx.project().succeeding_rebases;
|
let succeeding_rebases = ctx.project().succeeding_rebases;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use gitbutler_repo::{
|
|||||||
rebase::{cherry_rebase_group, gitbutler_merge_commits},
|
rebase::{cherry_rebase_group, gitbutler_merge_commits},
|
||||||
LogUntil, RepoActionsExt as _, RepositoryExt as _,
|
LogUntil, RepoActionsExt as _, RepositoryExt as _,
|
||||||
};
|
};
|
||||||
use gitbutler_stack::{Branch, BranchId, Target, VirtualBranchesHandle};
|
use gitbutler_stack::{Stack, StackId, Target, VirtualBranchesHandle};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -29,7 +29,7 @@ pub enum BranchStatus {
|
|||||||
#[serde(tag = "type", content = "subject", rename_all = "camelCase")]
|
#[serde(tag = "type", content = "subject", rename_all = "camelCase")]
|
||||||
pub enum BranchStatuses {
|
pub enum BranchStatuses {
|
||||||
UpToDate,
|
UpToDate,
|
||||||
UpdatesRequired(Vec<(BranchId, BranchStatus)>),
|
UpdatesRequired(Vec<(StackId, BranchStatus)>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||||
@ -74,7 +74,7 @@ impl BranchStatus {
|
|||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Resolution {
|
pub struct Resolution {
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
/// Used to ensure a given branch hasn't changed since the UI issued the command.
|
/// Used to ensure a given branch hasn't changed since the UI issued the command.
|
||||||
#[serde(with = "gitbutler_serde::oid")]
|
#[serde(with = "gitbutler_serde::oid")]
|
||||||
branch_tree: git2::Oid,
|
branch_tree: git2::Oid,
|
||||||
@ -90,7 +90,7 @@ enum IntegrationResult {
|
|||||||
pub struct UpstreamIntegrationContext<'a> {
|
pub struct UpstreamIntegrationContext<'a> {
|
||||||
_permission: Option<&'a mut WorktreeWritePermission>,
|
_permission: Option<&'a mut WorktreeWritePermission>,
|
||||||
repository: &'a git2::Repository,
|
repository: &'a git2::Repository,
|
||||||
virtual_branches_in_workspace: Vec<Branch>,
|
virtual_branches_in_workspace: Vec<Stack>,
|
||||||
new_target: git2::Commit<'a>,
|
new_target: git2::Commit<'a>,
|
||||||
old_target: git2::Commit<'a>,
|
old_target: git2::Commit<'a>,
|
||||||
target_branch_name: String,
|
target_branch_name: String,
|
||||||
@ -391,7 +391,7 @@ fn compute_resolutions(
|
|||||||
context: &UpstreamIntegrationContext,
|
context: &UpstreamIntegrationContext,
|
||||||
resolutions: &[Resolution],
|
resolutions: &[Resolution],
|
||||||
base_branch_resolution_approach: Option<BaseBranchResolutionApproach>,
|
base_branch_resolution_approach: Option<BaseBranchResolutionApproach>,
|
||||||
) -> Result<Vec<(BranchId, IntegrationResult)>> {
|
) -> Result<Vec<(StackId, IntegrationResult)>> {
|
||||||
let UpstreamIntegrationContext {
|
let UpstreamIntegrationContext {
|
||||||
repository,
|
repository,
|
||||||
new_target,
|
new_target,
|
||||||
@ -502,8 +502,8 @@ mod test {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn make_branch(head: git2::Oid, tree: git2::Oid) -> Branch {
|
fn make_branch(head: git2::Oid, tree: git2::Oid) -> Stack {
|
||||||
let mut branch = Branch::new(
|
let mut branch = Stack::new(
|
||||||
"branchy branch".into(),
|
"branchy branch".into(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -27,9 +27,9 @@ use gitbutler_repo::{
|
|||||||
LogUntil, RepoActionsExt, RepositoryExt,
|
LogUntil, RepoActionsExt, RepositoryExt,
|
||||||
};
|
};
|
||||||
use gitbutler_stack::{
|
use gitbutler_stack::{
|
||||||
reconcile_claims, Branch, BranchId, BranchOwnershipClaims, Target, VirtualBranchesHandle,
|
reconcile_claims, BranchOwnershipClaims, Stack, StackId, Target, VirtualBranchesHandle,
|
||||||
};
|
};
|
||||||
use gitbutler_stack_api::{commit_by_oid_or_change_id, Stack};
|
use gitbutler_stack_api::{commit_by_oid_or_change_id, StackActions};
|
||||||
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;
|
||||||
@ -47,7 +47,7 @@ use tracing::instrument;
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
pub struct VirtualBranch {
|
pub struct VirtualBranch {
|
||||||
pub id: BranchId,
|
pub id: StackId,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub notes: String,
|
pub notes: String,
|
||||||
pub active: bool,
|
pub active: bool,
|
||||||
@ -209,7 +209,7 @@ pub fn unapply_ownership(
|
|||||||
// reset a file in the project to the index state
|
// reset a file in the project to the index state
|
||||||
pub(crate) fn reset_files(
|
pub(crate) fn reset_files(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
files: &[PathBuf],
|
files: &[PathBuf],
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -469,7 +469,7 @@ pub fn list_virtual_branches_cached(
|
|||||||
/// Newest first, oldest last in the list
|
/// Newest first, oldest last in the list
|
||||||
fn stack_series(
|
fn stack_series(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch: &Branch,
|
branch: &Stack,
|
||||||
default_target: &Target,
|
default_target: &Target,
|
||||||
check_commit: &IsCommitIntegrated,
|
check_commit: &IsCommitIntegrated,
|
||||||
) -> Result<Vec<PatchSeries>> {
|
) -> Result<Vec<PatchSeries>> {
|
||||||
@ -563,7 +563,7 @@ fn branches_with_large_files_abridged(mut branches: Vec<VirtualBranch>) -> Vec<V
|
|||||||
branches
|
branches
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_requires_force(ctx: &CommandContext, branch: &Branch) -> Result<bool> {
|
fn is_requires_force(ctx: &CommandContext, branch: &Stack) -> Result<bool> {
|
||||||
let upstream = if let Some(upstream) = &branch.upstream {
|
let upstream = if let Some(upstream) = &branch.upstream {
|
||||||
upstream
|
upstream
|
||||||
} else {
|
} else {
|
||||||
@ -613,7 +613,7 @@ fn is_requires_force(ctx: &CommandContext, branch: &Branch) -> Result<bool> {
|
|||||||
/// might introduce more conflicts, but there is no need to commit at the
|
/// might introduce more conflicts, but there is no need to commit at the
|
||||||
/// end since there will only be one parent commit.
|
/// end since there will only be one parent commit.
|
||||||
///
|
///
|
||||||
pub fn integrate_upstream_commits(ctx: &CommandContext, branch_id: BranchId) -> Result<()> {
|
pub fn integrate_upstream_commits(ctx: &CommandContext, branch_id: StackId) -> Result<()> {
|
||||||
conflicts::is_conflicting(ctx, None)?;
|
conflicts::is_conflicting(ctx, None)?;
|
||||||
|
|
||||||
let repo = ctx.repository();
|
let repo = ctx.repository();
|
||||||
@ -733,7 +733,7 @@ pub fn integrate_upstream_commits(ctx: &CommandContext, branch_id: BranchId) ->
|
|||||||
|
|
||||||
pub(crate) fn integrate_with_rebase(
|
pub(crate) fn integrate_with_rebase(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch: &mut Branch,
|
branch: &mut Stack,
|
||||||
unknown_commits: &mut Vec<git2::Oid>,
|
unknown_commits: &mut Vec<git2::Oid>,
|
||||||
) -> Result<git2::Oid> {
|
) -> Result<git2::Oid> {
|
||||||
cherry_rebase_group(
|
cherry_rebase_group(
|
||||||
@ -746,7 +746,7 @@ pub(crate) fn integrate_with_rebase(
|
|||||||
|
|
||||||
pub(crate) fn integrate_with_merge(
|
pub(crate) fn integrate_with_merge(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch: &mut Branch,
|
branch: &mut Stack,
|
||||||
upstream_commit: &git2::Commit,
|
upstream_commit: &git2::Commit,
|
||||||
merge_base: git2::Oid,
|
merge_base: git2::Oid,
|
||||||
) -> Result<git2::Oid> {
|
) -> Result<git2::Oid> {
|
||||||
@ -794,7 +794,7 @@ pub(crate) fn integrate_with_merge(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_branch(ctx: &CommandContext, branch_update: &BranchUpdateRequest) -> Result<Branch> {
|
pub fn update_branch(ctx: &CommandContext, branch_update: &BranchUpdateRequest) -> Result<Stack> {
|
||||||
let vb_state = ctx.project().virtual_branches();
|
let vb_state = ctx.project().virtual_branches();
|
||||||
let mut branch = vb_state.get_branch_in_workspace(branch_update.id)?;
|
let mut branch = vb_state.get_branch_in_workspace(branch_update.id)?;
|
||||||
|
|
||||||
@ -898,7 +898,7 @@ pub(crate) fn ensure_selected_for_changes(vb_state: &VirtualBranchesHandle) -> R
|
|||||||
|
|
||||||
pub(crate) fn set_ownership(
|
pub(crate) fn set_ownership(
|
||||||
vb_state: &VirtualBranchesHandle,
|
vb_state: &VirtualBranchesHandle,
|
||||||
target_branch: &mut Branch,
|
target_branch: &mut Stack,
|
||||||
ownership: &BranchOwnershipClaims,
|
ownership: &BranchOwnershipClaims,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if target_branch.ownership.eq(ownership) {
|
if target_branch.ownership.eq(ownership) {
|
||||||
@ -932,7 +932,7 @@ pub type VirtualBranchHunksByPathMap = HashMap<PathBuf, Vec<VirtualBranchHunk>>;
|
|||||||
// reset virtual branch to a specific commit
|
// reset virtual branch to a specific commit
|
||||||
pub(crate) fn reset_branch(
|
pub(crate) fn reset_branch(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
target_commit_id: git2::Oid,
|
target_commit_id: git2::Oid,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let vb_state = ctx.project().virtual_branches();
|
let vb_state = ctx.project().virtual_branches();
|
||||||
@ -1005,7 +1005,7 @@ pub(crate) fn reset_branch(
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn commit(
|
pub fn commit(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
message: &str,
|
message: &str,
|
||||||
ownership: Option<&BranchOwnershipClaims>,
|
ownership: Option<&BranchOwnershipClaims>,
|
||||||
run_hooks: bool,
|
run_hooks: bool,
|
||||||
@ -1139,9 +1139,9 @@ pub fn commit(
|
|||||||
|
|
||||||
pub(crate) fn push(
|
pub(crate) fn push(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
askpass: Option<Option<BranchId>>,
|
askpass: Option<Option<StackId>>,
|
||||||
) -> Result<PushResult> {
|
) -> Result<PushResult> {
|
||||||
let vb_state = ctx.project().virtual_branches();
|
let vb_state = ctx.project().virtual_branches();
|
||||||
|
|
||||||
@ -1324,7 +1324,7 @@ pub fn is_remote_branch_mergeable(
|
|||||||
// then added to the "to" commit and everything above that rebased again.
|
// then added to the "to" commit and everything above that rebased again.
|
||||||
pub(crate) fn move_commit_file(
|
pub(crate) fn move_commit_file(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
from_commit_id: git2::Oid,
|
from_commit_id: git2::Oid,
|
||||||
to_commit_id: git2::Oid,
|
to_commit_id: git2::Oid,
|
||||||
target_ownership: &BranchOwnershipClaims,
|
target_ownership: &BranchOwnershipClaims,
|
||||||
@ -1562,7 +1562,7 @@ pub(crate) fn move_commit_file(
|
|||||||
// and the respective branch head is updated
|
// and the respective branch head is updated
|
||||||
pub(crate) fn amend(
|
pub(crate) fn amend(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
target_ownership: &BranchOwnershipClaims,
|
target_ownership: &BranchOwnershipClaims,
|
||||||
) -> Result<git2::Oid> {
|
) -> Result<git2::Oid> {
|
||||||
@ -1689,7 +1689,7 @@ pub(crate) fn amend(
|
|||||||
// return the oid of the new head commit of the branch with the inserted blank commit
|
// return the oid of the new head commit of the branch with the inserted blank commit
|
||||||
pub(crate) fn insert_blank_commit(
|
pub(crate) fn insert_blank_commit(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: git2::Oid,
|
commit_oid: git2::Oid,
|
||||||
offset: i32,
|
offset: i32,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -1739,11 +1739,7 @@ pub(crate) fn insert_blank_commit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// squashes a commit from a virtual branch into its parent.
|
/// squashes a commit from a virtual branch into its parent.
|
||||||
pub(crate) fn squash(
|
pub(crate) fn squash(ctx: &CommandContext, branch_id: StackId, commit_id: git2::Oid) -> Result<()> {
|
||||||
ctx: &CommandContext,
|
|
||||||
branch_id: BranchId,
|
|
||||||
commit_id: git2::Oid,
|
|
||||||
) -> Result<()> {
|
|
||||||
ctx.assure_resolved()?;
|
ctx.assure_resolved()?;
|
||||||
|
|
||||||
let vb_state = ctx.project().virtual_branches();
|
let vb_state = ctx.project().virtual_branches();
|
||||||
@ -1843,7 +1839,7 @@ pub(crate) fn squash(
|
|||||||
// changes a commit message for commit_oid, rebases everything above it, updates branch head if successful
|
// changes a commit message for commit_oid, rebases everything above it, updates branch head if successful
|
||||||
pub(crate) fn update_commit_message(
|
pub(crate) fn update_commit_message(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_id: git2::Oid,
|
commit_id: git2::Oid,
|
||||||
message: &str,
|
message: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use gitbutler_stack::Branch;
|
use gitbutler_stack::Stack;
|
||||||
|
|
||||||
/// Makes a Branch struct with a bunch of default values.
|
/// Makes a Branch struct with a bunch of default values.
|
||||||
///
|
///
|
||||||
/// This assumes that the only relevant properties for your test are the head
|
/// This assumes that the only relevant properties for your test are the head
|
||||||
/// and tree Oids.
|
/// and tree Oids.
|
||||||
fn make_branch(head: git2::Oid, tree: git2::Oid) -> Branch {
|
fn make_branch(head: git2::Oid, tree: git2::Oid) -> Stack {
|
||||||
let mut branch = Branch::new(
|
let mut branch = Stack::new(
|
||||||
"branchy branch".into(),
|
"branchy branch".into(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
|
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
|
||||||
use gitbutler_branch_actions::VirtualBranch;
|
use gitbutler_branch_actions::VirtualBranch;
|
||||||
use gitbutler_id::id::Id;
|
use gitbutler_id::id::Id;
|
||||||
use gitbutler_stack::Branch;
|
use gitbutler_stack::Stack;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ fn commit_and_push_initial(repository: &TestProject) {
|
|||||||
repository.push();
|
repository.push();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_virtual_branch(project: &Project, branch_id: Id<Branch>) -> VirtualBranch {
|
fn get_virtual_branch(project: &Project, branch_id: Id<Stack>) -> VirtualBranch {
|
||||||
gitbutler_branch_actions::list_virtual_branches(project)
|
gitbutler_branch_actions::list_virtual_branches(project)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.0
|
.0
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use bstr::ByteSlice;
|
use bstr::ByteSlice;
|
||||||
use gitbutler_branch::BranchCreateRequest;
|
use gitbutler_branch::BranchCreateRequest;
|
||||||
use gitbutler_stack::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
use std::{path::PathBuf, str::FromStr};
|
use std::{path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
use super::Test;
|
use super::Test;
|
||||||
@ -654,7 +654,7 @@ fn no_branch() {
|
|||||||
gitbutler_branch_actions::create_commit(project, source_branch_id, "commit", None, false)
|
gitbutler_branch_actions::create_commit(project, source_branch_id, "commit", None, false)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let id = BranchId::generate();
|
let id = StackId::generate();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gitbutler_branch_actions::move_commit(project, id, commit_oid)
|
gitbutler_branch_actions::move_commit(project, id, commit_oid)
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use bstr::{BStr, ByteSlice};
|
use bstr::{BStr, ByteSlice};
|
||||||
use gitbutler_stack::{BranchId, BranchOwnershipClaims};
|
use gitbutler_stack::{BranchOwnershipClaims, StackId};
|
||||||
use serde::{Deserialize, Serialize, Serializer};
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
||||||
pub struct BranchUpdateRequest {
|
pub struct BranchUpdateRequest {
|
||||||
pub id: BranchId,
|
pub id: StackId,
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub notes: Option<String>,
|
pub notes: Option<String>,
|
||||||
pub ownership: Option<BranchOwnershipClaims>,
|
pub ownership: Option<BranchOwnershipClaims>,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use gitbutler_reference::ReferenceName;
|
use gitbutler_reference::ReferenceName;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use gitbutler_stack::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
|
|
||||||
/// GitButler reference associated with a change (commit) on a virtual branch.
|
/// 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.
|
/// These are not the same as regular Git references, but rather app-managed refs.
|
||||||
@ -11,7 +11,7 @@ use gitbutler_stack::BranchId;
|
|||||||
pub struct ChangeReference {
|
pub struct ChangeReference {
|
||||||
/// Branch id of the virtual branch this reference belongs to
|
/// Branch id of the virtual branch this reference belongs to
|
||||||
/// Multiple references may belong to the same virtual branch, representing separate deployable / reviewable parts of the vbranch.
|
/// Multiple references may belong to the same virtual branch, representing separate deployable / reviewable parts of the vbranch.
|
||||||
pub branch_id: BranchId,
|
pub branch_id: StackId,
|
||||||
/// Fully qualified reference name.
|
/// Fully qualified reference name.
|
||||||
/// The reference must be a remote reference.
|
/// The reference must be a remote reference.
|
||||||
pub name: ReferenceName,
|
pub name: ReferenceName,
|
||||||
|
@ -3,7 +3,7 @@ use gitbutler_branch::{BranchCreateRequest, BranchIdentity, BranchUpdateRequest}
|
|||||||
use gitbutler_branch_actions::{get_branch_listing_details, list_branches};
|
use gitbutler_branch_actions::{get_branch_listing_details, list_branches};
|
||||||
use gitbutler_command_context::CommandContext;
|
use gitbutler_command_context::CommandContext;
|
||||||
use gitbutler_project::Project;
|
use gitbutler_project::Project;
|
||||||
use gitbutler_stack::{Branch, VirtualBranchesHandle};
|
use gitbutler_stack::{Stack, VirtualBranchesHandle};
|
||||||
|
|
||||||
use crate::command::debug_print;
|
use crate::command::debug_print;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ pub fn set_default(project: Project, branch_name: String) -> Result<()> {
|
|||||||
set_default_branch(&project, &branch)
|
set_default_branch(&project, &branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_default_branch(project: &Project, branch: &Branch) -> Result<()> {
|
fn set_default_branch(project: &Project, branch: &Stack) -> Result<()> {
|
||||||
gitbutler_branch_actions::update_virtual_branch(
|
gitbutler_branch_actions::update_virtual_branch(
|
||||||
project,
|
project,
|
||||||
BranchUpdateRequest {
|
BranchUpdateRequest {
|
||||||
@ -143,7 +143,7 @@ pub fn commit(project: Project, branch_name: String, message: String) -> Result<
|
|||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn branch_by_name(project: &Project, name: &str) -> Result<Branch> {
|
pub fn branch_by_name(project: &Project, name: &str) -> Result<Stack> {
|
||||||
let mut found: Vec<_> = VirtualBranchesHandle::new(project.gb_dir())
|
let mut found: Vec<_> = VirtualBranchesHandle::new(project.gb_dir())
|
||||||
.list_all_branches()?
|
.list_all_branches()?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -23,7 +23,7 @@ use gitbutler_operating_modes::{
|
|||||||
use gitbutler_project::access::{WorktreeReadPermission, WorktreeWritePermission};
|
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_stack::{Branch, VirtualBranchesHandle};
|
use gitbutler_stack::{Stack, VirtualBranchesHandle};
|
||||||
|
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ fn checkout_edit_branch(ctx: &CommandContext, commit: &git2::Commit) -> Result<(
|
|||||||
fn find_virtual_branch_by_reference(
|
fn find_virtual_branch_by_reference(
|
||||||
ctx: &CommandContext,
|
ctx: &CommandContext,
|
||||||
reference: &ReferenceName,
|
reference: &ReferenceName,
|
||||||
) -> Result<Option<Branch>> {
|
) -> Result<Option<Stack>> {
|
||||||
let vb_state = VirtualBranchesHandle::new(ctx.project().gb_dir());
|
let vb_state = VirtualBranchesHandle::new(ctx.project().gb_dir());
|
||||||
let all_virtual_branches = vb_state
|
let all_virtual_branches = vb_state
|
||||||
.list_branches_in_workspace()
|
.list_branches_in_workspace()
|
||||||
|
@ -16,7 +16,7 @@ use gitbutler_project::{
|
|||||||
Project,
|
Project,
|
||||||
};
|
};
|
||||||
use gitbutler_repo::RepositoryExt;
|
use gitbutler_repo::RepositoryExt;
|
||||||
use gitbutler_stack::{Branch, VirtualBranchesHandle, VirtualBranchesState};
|
use gitbutler_stack::{Stack, VirtualBranchesHandle, VirtualBranchesState};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@ -732,7 +732,7 @@ fn lines_since_snapshot(project: &Project, repo: &git2::Repository) -> Result<us
|
|||||||
|
|
||||||
#[instrument(level = tracing::Level::DEBUG, skip(branch, repo), err(Debug))]
|
#[instrument(level = tracing::Level::DEBUG, skip(branch, repo), err(Debug))]
|
||||||
fn branch_lines_since_snapshot(
|
fn branch_lines_since_snapshot(
|
||||||
branch: &Branch,
|
branch: &Stack,
|
||||||
repo: &git2::Repository,
|
repo: &git2::Repository,
|
||||||
head_sha: git2::Oid,
|
head_sha: git2::Oid,
|
||||||
) -> Result<usize> {
|
) -> Result<usize> {
|
||||||
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
|||||||
use gitbutler_branch::BranchUpdateRequest;
|
use gitbutler_branch::BranchUpdateRequest;
|
||||||
use gitbutler_project::{access::WorktreeWritePermission, Project};
|
use gitbutler_project::{access::WorktreeWritePermission, Project};
|
||||||
use gitbutler_reference::ReferenceName;
|
use gitbutler_reference::ReferenceName;
|
||||||
use gitbutler_stack::Branch;
|
use gitbutler_stack::Stack;
|
||||||
|
|
||||||
use super::entry::Trailer;
|
use super::entry::Trailer;
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -50,7 +50,7 @@ pub trait SnapshotExt {
|
|||||||
fn snapshot_branch_update(
|
fn snapshot_branch_update(
|
||||||
&self,
|
&self,
|
||||||
snapshot_tree: git2::Oid,
|
snapshot_tree: git2::Oid,
|
||||||
old_branch: &Branch,
|
old_branch: &Stack,
|
||||||
update: &BranchUpdateRequest,
|
update: &BranchUpdateRequest,
|
||||||
error: Option<&anyhow::Error>,
|
error: Option<&anyhow::Error>,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
@ -141,7 +141,7 @@ impl SnapshotExt for Project {
|
|||||||
fn snapshot_branch_update(
|
fn snapshot_branch_update(
|
||||||
&self,
|
&self,
|
||||||
snapshot_tree: git2::Oid,
|
snapshot_tree: git2::Oid,
|
||||||
old_branch: &Branch,
|
old_branch: &Stack,
|
||||||
update: &BranchUpdateRequest,
|
update: &BranchUpdateRequest,
|
||||||
error: Option<&anyhow::Error>,
|
error: Option<&anyhow::Error>,
|
||||||
perm: &mut WorktreeWritePermission,
|
perm: &mut WorktreeWritePermission,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::{collections::HashMap, path::Path, sync::Arc};
|
use std::{collections::HashMap, path::Path, sync::Arc};
|
||||||
|
|
||||||
use gitbutler_id::id::Id;
|
use gitbutler_id::id::Id;
|
||||||
use gitbutler_stack::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio::sync::{oneshot, Mutex};
|
use tokio::sync::{oneshot, Mutex};
|
||||||
|
|
||||||
@ -38,9 +38,9 @@ pub struct AskpassRequest {
|
|||||||
// This is needed to end up with a struct with either `branch_id` or `action`
|
// This is needed to end up with a struct with either `branch_id` or `action`
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Context {
|
pub enum Context {
|
||||||
Push { branch_id: Option<BranchId> },
|
Push { branch_id: Option<StackId> },
|
||||||
Fetch { action: String },
|
Fetch { action: String },
|
||||||
SignedCommit { branch_id: Option<BranchId> },
|
SignedCommit { branch_id: Option<StackId> },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -89,7 +89,7 @@ impl AskpassBroker {
|
|||||||
|
|
||||||
async fn handle_git_prompt_commit_sign_sync(
|
async fn handle_git_prompt_commit_sign_sync(
|
||||||
prompt: String,
|
prompt: String,
|
||||||
branch_id: Option<BranchId>,
|
branch_id: Option<StackId>,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
tracing::info!("received prompt for synchronous signed commit {branch_id:?}: {prompt:?}");
|
tracing::info!("received prompt for synchronous signed commit {branch_id:?}: {prompt:?}");
|
||||||
get_broker()
|
get_broker()
|
||||||
@ -103,7 +103,7 @@ async fn handle_git_prompt_commit_sign_sync(
|
|||||||
pub fn sign_commit_sync(
|
pub fn sign_commit_sync(
|
||||||
repo_path: impl AsRef<Path>,
|
repo_path: impl AsRef<Path>,
|
||||||
base_commitish: impl AsRef<str>,
|
base_commitish: impl AsRef<str>,
|
||||||
branch_id: Option<BranchId>,
|
branch_id: Option<StackId>,
|
||||||
) -> Result<String, impl std::error::Error> {
|
) -> Result<String, impl std::error::Error> {
|
||||||
let repo_path = repo_path.as_ref().to_path_buf();
|
let repo_path = repo_path.as_ref().to_path_buf();
|
||||||
let base_commitish: &str = base_commitish.as_ref();
|
let base_commitish: &str = base_commitish.as_ref();
|
||||||
|
@ -6,7 +6,7 @@ use gitbutler_commit::commit_headers::CommitHeadersV2;
|
|||||||
use gitbutler_error::error::Code;
|
use gitbutler_error::error::Code;
|
||||||
use gitbutler_project::AuthKey;
|
use gitbutler_project::AuthKey;
|
||||||
use gitbutler_reference::{Refname, RemoteRefname};
|
use gitbutler_reference::{Refname, RemoteRefname};
|
||||||
use gitbutler_stack::{Branch, BranchId};
|
use gitbutler_stack::{Stack, StackId};
|
||||||
|
|
||||||
use crate::{askpass, credentials, RepositoryExt};
|
use crate::{askpass, credentials, RepositoryExt};
|
||||||
pub trait RepoActionsExt {
|
pub trait RepoActionsExt {
|
||||||
@ -17,7 +17,7 @@ pub trait RepoActionsExt {
|
|||||||
branch: &RemoteRefname,
|
branch: &RemoteRefname,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
refspec: Option<String>,
|
refspec: Option<String>,
|
||||||
askpass_broker: Option<Option<BranchId>>,
|
askpass_broker: Option<Option<StackId>>,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
fn commit(
|
fn commit(
|
||||||
&self,
|
&self,
|
||||||
@ -27,13 +27,13 @@ pub trait RepoActionsExt {
|
|||||||
commit_headers: Option<CommitHeadersV2>,
|
commit_headers: Option<CommitHeadersV2>,
|
||||||
) -> Result<git2::Oid>;
|
) -> Result<git2::Oid>;
|
||||||
fn distance(&self, from: git2::Oid, to: git2::Oid) -> Result<u32>;
|
fn distance(&self, from: git2::Oid, to: git2::Oid) -> Result<u32>;
|
||||||
fn delete_branch_reference(&self, branch: &Branch) -> Result<()>;
|
fn delete_branch_reference(&self, branch: &Stack) -> Result<()>;
|
||||||
fn add_branch_reference(&self, branch: &Branch) -> Result<()>;
|
fn add_branch_reference(&self, branch: &Stack) -> Result<()>;
|
||||||
fn git_test_push(
|
fn git_test_push(
|
||||||
&self,
|
&self,
|
||||||
remote_name: &str,
|
remote_name: &str,
|
||||||
branch_name: &str,
|
branch_name: &str,
|
||||||
askpass: Option<Option<BranchId>>,
|
askpass: Option<Option<StackId>>,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ impl RepoActionsExt for CommandContext {
|
|||||||
&self,
|
&self,
|
||||||
remote_name: &str,
|
remote_name: &str,
|
||||||
branch_name: &str,
|
branch_name: &str,
|
||||||
askpass: Option<Option<BranchId>>,
|
askpass: Option<Option<StackId>>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let target_branch_refname =
|
let target_branch_refname =
|
||||||
Refname::from_str(&format!("refs/remotes/{}/{}", remote_name, branch_name))?;
|
Refname::from_str(&format!("refs/remotes/{}/{}", remote_name, branch_name))?;
|
||||||
@ -73,7 +73,7 @@ impl RepoActionsExt for CommandContext {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_branch_reference(&self, branch: &Branch) -> Result<()> {
|
fn add_branch_reference(&self, branch: &Stack) -> Result<()> {
|
||||||
let (should_write, with_force) = match self
|
let (should_write, with_force) = match self
|
||||||
.repository()
|
.repository()
|
||||||
.find_reference(&branch.refname()?.to_string())
|
.find_reference(&branch.refname()?.to_string())
|
||||||
@ -103,7 +103,7 @@ impl RepoActionsExt for CommandContext {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_branch_reference(&self, branch: &Branch) -> Result<()> {
|
fn delete_branch_reference(&self, branch: &Stack) -> Result<()> {
|
||||||
match self
|
match self
|
||||||
.repository()
|
.repository()
|
||||||
.find_reference(&branch.refname()?.to_string())
|
.find_reference(&branch.refname()?.to_string())
|
||||||
@ -158,7 +158,7 @@ impl RepoActionsExt for CommandContext {
|
|||||||
branch: &RemoteRefname,
|
branch: &RemoteRefname,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
refspec: Option<String>,
|
refspec: Option<String>,
|
||||||
askpass_broker: Option<Option<BranchId>>,
|
askpass_broker: Option<Option<StackId>>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let refspec = refspec.unwrap_or_else(|| {
|
let refspec = refspec.unwrap_or_else(|| {
|
||||||
if with_force {
|
if with_force {
|
||||||
@ -335,7 +335,7 @@ pub enum LogUntil {
|
|||||||
|
|
||||||
async fn handle_git_prompt_push(
|
async fn handle_git_prompt_push(
|
||||||
prompt: String,
|
prompt: String,
|
||||||
askpass: Option<Option<BranchId>>,
|
askpass: Option<Option<StackId>>,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
if let Some(branch_id) = askpass {
|
if let Some(branch_id) = askpass {
|
||||||
tracing::info!("received prompt for branch push {branch_id:?}: {prompt:?}");
|
tracing::info!("received prompt for branch push {branch_id:?}: {prompt:?}");
|
||||||
|
@ -2,4 +2,4 @@ mod heads;
|
|||||||
mod series;
|
mod series;
|
||||||
mod stack;
|
mod stack;
|
||||||
pub use series::Series;
|
pub use series::Series;
|
||||||
pub use stack::{commit_by_oid_or_change_id, PatchReferenceUpdate, Stack, TargetUpdate};
|
pub use stack::{commit_by_oid_or_change_id, PatchReferenceUpdate, StackActions, TargetUpdate};
|
||||||
|
@ -12,7 +12,7 @@ use gitbutler_reference::RemoteRefname;
|
|||||||
use gitbutler_repo::LogUntil;
|
use gitbutler_repo::LogUntil;
|
||||||
use gitbutler_repo::RepoActionsExt;
|
use gitbutler_repo::RepoActionsExt;
|
||||||
use gitbutler_repo::RepositoryExt;
|
use gitbutler_repo::RepositoryExt;
|
||||||
use gitbutler_stack::Branch;
|
use gitbutler_stack::Stack;
|
||||||
use gitbutler_stack::Target;
|
use gitbutler_stack::Target;
|
||||||
use gitbutler_stack::VirtualBranchesHandle;
|
use gitbutler_stack::VirtualBranchesHandle;
|
||||||
use gix::validate::reference::name_partial;
|
use gix::validate::reference::name_partial;
|
||||||
@ -30,7 +30,7 @@ use crate::series::Series;
|
|||||||
/// - have at least one head (branch)
|
/// - have at least one head (branch)
|
||||||
/// - include only referecences that are part of the stack
|
/// - include only referecences that are part of the stack
|
||||||
/// - always have it's commits under a reference i.e. no orphaned commits
|
/// - always have it's commits under a reference i.e. no orphaned commits
|
||||||
pub trait Stack {
|
pub trait StackActions {
|
||||||
/// An initialized stack has at least one head (branch).
|
/// An initialized stack has at least one head (branch).
|
||||||
fn initialized(&self) -> bool;
|
fn initialized(&self) -> bool;
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ pub struct TargetUpdate {
|
|||||||
/// The first patches are in the beginning of the list and the most recent patches are at the end of the list (top of the stack)
|
/// The first patches are in the beginning of the list and the most recent patches are at the end of the list (top of the stack)
|
||||||
/// Similarly, heads that point to earlier commits are first in the order, and the last head always points to the most recent patch.
|
/// Similarly, heads that point to earlier commits are first in the order, and the last head always points to the most recent patch.
|
||||||
/// If there are multiple heads that point to the same patch, the `add` and `update` operations can specify the intended order.
|
/// If there are multiple heads that point to the same patch, the `add` and `update` operations can specify the intended order.
|
||||||
impl Stack for Branch {
|
impl StackActions for Stack {
|
||||||
fn initialized(&self) -> bool {
|
fn initialized(&self) -> bool {
|
||||||
!self.heads.is_empty()
|
!self.heads.is_empty()
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use gitbutler_commit::commit_ext::CommitExt;
|
|||||||
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
|
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
|
||||||
use gitbutler_repo::{LogUntil, RepositoryExt as _};
|
use gitbutler_repo::{LogUntil, RepositoryExt as _};
|
||||||
use gitbutler_stack::VirtualBranchesHandle;
|
use gitbutler_stack::VirtualBranchesHandle;
|
||||||
use gitbutler_stack_api::{PatchReferenceUpdate, Stack, TargetUpdate};
|
use gitbutler_stack_api::{PatchReferenceUpdate, StackActions, TargetUpdate};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
@ -788,7 +788,7 @@ fn test_ctx(ctx: &CommandContext) -> Result<TestContext> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
struct TestContext<'a> {
|
struct TestContext<'a> {
|
||||||
branch: gitbutler_stack::Branch,
|
branch: gitbutler_stack::Stack,
|
||||||
/// Oldest commit first
|
/// Oldest commit first
|
||||||
commits: Vec<git2::Commit<'a>>,
|
commits: Vec<git2::Commit<'a>>,
|
||||||
/// Oldest commit first
|
/// Oldest commit first
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
mod branch;
|
|
||||||
mod file_ownership;
|
mod file_ownership;
|
||||||
mod ownership;
|
mod ownership;
|
||||||
|
mod stack;
|
||||||
mod state;
|
mod state;
|
||||||
mod target;
|
mod target;
|
||||||
|
|
||||||
pub use branch::{Branch, BranchId};
|
|
||||||
pub use file_ownership::OwnershipClaim;
|
pub use file_ownership::OwnershipClaim;
|
||||||
pub use ownership::{reconcile_claims, BranchOwnershipClaims, ClaimOutcome};
|
pub use ownership::{reconcile_claims, BranchOwnershipClaims, ClaimOutcome};
|
||||||
|
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;
|
||||||
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use serde::{Deserialize, Serialize, Serializer};
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
|
|
||||||
use crate::{file_ownership::OwnershipClaim, Branch};
|
use crate::{file_ownership::OwnershipClaim, Stack};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||||
pub struct BranchOwnershipClaims {
|
pub struct BranchOwnershipClaims {
|
||||||
@ -93,12 +93,12 @@ impl BranchOwnershipClaims {
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ClaimOutcome {
|
pub struct ClaimOutcome {
|
||||||
pub updated_branch: Branch,
|
pub updated_branch: Stack,
|
||||||
pub removed_claims: Vec<OwnershipClaim>,
|
pub removed_claims: Vec<OwnershipClaim>,
|
||||||
}
|
}
|
||||||
pub fn reconcile_claims(
|
pub fn reconcile_claims(
|
||||||
all_branches: Vec<Branch>,
|
all_branches: Vec<Stack>,
|
||||||
claiming_branch: &Branch,
|
claiming_branch: &Stack,
|
||||||
new_claims: &[OwnershipClaim],
|
new_claims: &[OwnershipClaim],
|
||||||
) -> Result<Vec<ClaimOutcome>> {
|
) -> Result<Vec<ClaimOutcome>> {
|
||||||
let mut other_branches = all_branches
|
let mut other_branches = all_branches
|
||||||
|
@ -6,15 +6,15 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::ownership::BranchOwnershipClaims;
|
use crate::ownership::BranchOwnershipClaims;
|
||||||
|
|
||||||
pub type BranchId = Id<Branch>;
|
pub type StackId = Id<Stack>;
|
||||||
|
|
||||||
// this is the struct for the virtual branch data that is stored in our data
|
// this is the struct for the virtual branch data that is stored in our data
|
||||||
// store. it is more or less equivalent to a git branch reference, but it is not
|
// store. it is more or less equivalent to a git branch reference, but it is not
|
||||||
// stored or accessible from the git repository itself. it is stored in our
|
// stored or accessible from the git repository itself. it is stored in our
|
||||||
// session storage under the branches/ directory.
|
// session storage under the branches/ directory.
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||||
pub struct Branch {
|
pub struct Stack {
|
||||||
pub id: BranchId,
|
pub id: StackId,
|
||||||
/// A user-specified name with no restrictions.
|
/// A user-specified name with no restrictions.
|
||||||
/// It will be normalized except to be a valid [ref-name](Branch::refname()) if named `refs/gitbutler/<normalize(name)>`.
|
/// It will be normalized except to be a valid [ref-name](Branch::refname()) if named `refs/gitbutler/<normalize(name)>`.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@ -83,7 +83,7 @@ where
|
|||||||
Ok(x)
|
Ok(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Branch {
|
impl Stack {
|
||||||
/// Creates a new `Branch` with the given name. The `in_workspace` flag is set to `true`.
|
/// Creates a new `Branch` with the given name. The `in_workspace` flag is set to `true`.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
@ -99,7 +99,7 @@ impl Branch {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
let now = gitbutler_time::time::now_ms();
|
let now = gitbutler_time::time::now_ms();
|
||||||
Self {
|
Self {
|
||||||
id: BranchId::generate(),
|
id: StackId::generate(),
|
||||||
name,
|
name,
|
||||||
notes: String::new(),
|
notes: String::new(),
|
||||||
source_refname,
|
source_refname,
|
||||||
@ -132,10 +132,10 @@ impl Branch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&Branch> for VirtualRefname {
|
impl TryFrom<&Stack> for VirtualRefname {
|
||||||
type Error = anyhow::Error;
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
fn try_from(value: &Branch) -> std::result::Result<Self, Self::Error> {
|
fn try_from(value: &Stack) -> std::result::Result<Self, Self::Error> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
branch: normalize_branch_name(&value.name)?,
|
branch: normalize_branch_name(&value.name)?,
|
||||||
})
|
})
|
@ -12,7 +12,7 @@ use itertools::Itertools;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
branch::{Branch, BranchId},
|
stack::{Stack, StackId},
|
||||||
target::Target,
|
target::Target,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -22,24 +22,24 @@ pub struct VirtualBranches {
|
|||||||
/// This is the target/base that is set when a repo is added to gb
|
/// This is the target/base that is set when a repo is added to gb
|
||||||
default_target: Option<Target>,
|
default_target: Option<Target>,
|
||||||
/// The targets for each virtual branch
|
/// The targets for each virtual branch
|
||||||
branch_targets: HashMap<BranchId, Target>,
|
branch_targets: HashMap<StackId, Target>,
|
||||||
/// The current state of the virtual branches
|
/// The current state of the virtual branches
|
||||||
branches: HashMap<BranchId, Branch>,
|
branches: HashMap<StackId, Stack>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualBranches {
|
impl VirtualBranches {
|
||||||
/// Lists all virtual branches that are in the user's workspace.
|
/// Lists all virtual branches that are in the user's workspace.
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub(crate) fn list_all_branches(&self) -> Result<Vec<Branch>> {
|
pub(crate) fn list_all_branches(&self) -> Result<Vec<Stack>> {
|
||||||
let branches: Vec<Branch> = self.branches.values().cloned().collect();
|
let branches: Vec<Stack> = self.branches.values().cloned().collect();
|
||||||
Ok(branches)
|
Ok(branches)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lists all virtual branches that are in the user's workspace.
|
/// Lists all virtual branches that are in the user's workspace.
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub fn list_branches_in_workspace(&self) -> Result<Vec<Branch>> {
|
pub fn list_branches_in_workspace(&self) -> Result<Vec<Stack>> {
|
||||||
self.list_all_branches().map(|branches| {
|
self.list_all_branches().map(|branches| {
|
||||||
branches
|
branches
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -97,7 +97,7 @@ impl VirtualBranchesHandle {
|
|||||||
/// Sets the state of the given virtual branch.
|
/// Sets the state of the given virtual branch.
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub fn set_branch(&self, branch: Branch) -> Result<()> {
|
pub fn set_branch(&self, branch: Stack) -> Result<()> {
|
||||||
let mut virtual_branches = self.read_file()?;
|
let mut virtual_branches = self.read_file()?;
|
||||||
virtual_branches.branches.insert(branch.id, branch);
|
virtual_branches.branches.insert(branch.id, branch);
|
||||||
self.write_file(&virtual_branches)?;
|
self.write_file(&virtual_branches)?;
|
||||||
@ -107,7 +107,7 @@ impl VirtualBranchesHandle {
|
|||||||
/// Marks a particular branch as not in the workspace
|
/// Marks a particular branch as not in the workspace
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub fn mark_as_not_in_workspace(&self, id: BranchId) -> Result<()> {
|
pub fn mark_as_not_in_workspace(&self, id: StackId) -> Result<()> {
|
||||||
let mut branch = self.get_branch(id)?;
|
let mut branch = self.get_branch(id)?;
|
||||||
branch.in_workspace = false;
|
branch.in_workspace = false;
|
||||||
self.set_branch(branch)?;
|
self.set_branch(branch)?;
|
||||||
@ -117,7 +117,7 @@ impl VirtualBranchesHandle {
|
|||||||
pub fn find_by_source_refname_where_not_in_workspace(
|
pub fn find_by_source_refname_where_not_in_workspace(
|
||||||
&self,
|
&self,
|
||||||
refname: &Refname,
|
refname: &Refname,
|
||||||
) -> Result<Option<Branch>> {
|
) -> Result<Option<Stack>> {
|
||||||
let branches = self.list_all_branches()?;
|
let branches = self.list_all_branches()?;
|
||||||
Ok(branches.into_iter().find(|branch| {
|
Ok(branches.into_iter().find(|branch| {
|
||||||
if branch.in_workspace {
|
if branch.in_workspace {
|
||||||
@ -135,7 +135,7 @@ impl VirtualBranchesHandle {
|
|||||||
/// Gets the state of the given virtual branch.
|
/// Gets the state of the given virtual branch.
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub fn get_branch_in_workspace(&self, id: BranchId) -> Result<Branch> {
|
pub fn get_branch_in_workspace(&self, id: StackId) -> Result<Stack> {
|
||||||
self.try_branch_in_workspace(id)?
|
self.try_branch_in_workspace(id)?
|
||||||
.ok_or_else(|| anyhow!("branch with ID {id} not found"))
|
.ok_or_else(|| anyhow!("branch with ID {id} not found"))
|
||||||
}
|
}
|
||||||
@ -143,20 +143,20 @@ impl VirtualBranchesHandle {
|
|||||||
/// Gets the state of the given virtual branch.
|
/// Gets the state of the given virtual branch.
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub fn get_branch(&self, id: BranchId) -> Result<Branch> {
|
pub fn get_branch(&self, id: StackId) -> Result<Stack> {
|
||||||
self.try_branch(id)?
|
self.try_branch(id)?
|
||||||
.ok_or_else(|| anyhow!("branch with ID {id} not found"))
|
.ok_or_else(|| anyhow!("branch with ID {id} not found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the state of the given virtual branch returning `Some(branch)` or `None`
|
/// Gets the state of the given virtual branch returning `Some(branch)` or `None`
|
||||||
/// if that branch doesn't exist.
|
/// if that branch doesn't exist.
|
||||||
pub fn try_branch_in_workspace(&self, id: BranchId) -> Result<Option<Branch>> {
|
pub fn try_branch_in_workspace(&self, id: StackId) -> Result<Option<Stack>> {
|
||||||
Ok(self.try_branch(id)?.filter(|branch| branch.in_workspace))
|
Ok(self.try_branch(id)?.filter(|branch| branch.in_workspace))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the state of the given virtual branch returning `Some(branch)` or `None`
|
/// Gets the state of the given virtual branch returning `Some(branch)` or `None`
|
||||||
/// if that branch doesn't exist.
|
/// if that branch doesn't exist.
|
||||||
pub fn try_branch(&self, id: BranchId) -> Result<Option<Branch>> {
|
pub fn try_branch(&self, id: StackId) -> Result<Option<Stack>> {
|
||||||
let virtual_branches = self.read_file()?;
|
let virtual_branches = self.read_file()?;
|
||||||
Ok(virtual_branches.branches.get(&id).cloned())
|
Ok(virtual_branches.branches.get(&id).cloned())
|
||||||
}
|
}
|
||||||
@ -164,16 +164,16 @@ impl VirtualBranchesHandle {
|
|||||||
/// Lists all branches in `virtual_branches.toml`.
|
/// Lists all branches in `virtual_branches.toml`.
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub fn list_all_branches(&self) -> Result<Vec<Branch>> {
|
pub fn list_all_branches(&self) -> Result<Vec<Stack>> {
|
||||||
let virtual_branches = self.read_file()?;
|
let virtual_branches = self.read_file()?;
|
||||||
let branches: Vec<Branch> = virtual_branches.branches.values().cloned().collect();
|
let branches: Vec<Stack> = virtual_branches.branches.values().cloned().collect();
|
||||||
Ok(branches)
|
Ok(branches)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lists all virtual branches that are in the user's workspace.
|
/// Lists all virtual branches that are in the user's workspace.
|
||||||
///
|
///
|
||||||
/// Errors if the file cannot be read or written.
|
/// Errors if the file cannot be read or written.
|
||||||
pub fn list_branches_in_workspace(&self) -> Result<Vec<Branch>> {
|
pub fn list_branches_in_workspace(&self) -> Result<Vec<Stack>> {
|
||||||
self.list_all_branches().map(|branches| {
|
self.list_all_branches().map(|branches| {
|
||||||
branches
|
branches
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -218,14 +218,14 @@ impl VirtualBranchesHandle {
|
|||||||
.list_branches_in_workspace()?
|
.list_branches_in_workspace()?
|
||||||
.iter()
|
.iter()
|
||||||
.sorted_by_key(|branch| branch.order)
|
.sorted_by_key(|branch| branch.order)
|
||||||
.collect::<Vec<&Branch>>()
|
.collect::<Vec<&Stack>>()
|
||||||
.last()
|
.last()
|
||||||
.map_or(0, |b| b.order + 1);
|
.map_or(0, |b| b.order + 1);
|
||||||
|
|
||||||
Ok(order)
|
Ok(order)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete_branch_entry(&self, branch_id: &BranchId) -> Result<()> {
|
pub fn delete_branch_entry(&self, branch_id: &StackId) -> Result<()> {
|
||||||
let mut virtual_branches = self.read_file()?;
|
let mut virtual_branches = self.read_file()?;
|
||||||
virtual_branches.branches.remove(branch_id);
|
virtual_branches.branches.remove(branch_id);
|
||||||
self.write_file(&virtual_branches)?;
|
self.write_file(&virtual_branches)?;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use std::{path::PathBuf, vec};
|
use std::{path::PathBuf, vec};
|
||||||
|
|
||||||
use gitbutler_diff::Hunk;
|
use gitbutler_diff::Hunk;
|
||||||
use gitbutler_stack::{reconcile_claims, Branch, BranchOwnershipClaims, OwnershipClaim};
|
use gitbutler_stack::{reconcile_claims, BranchOwnershipClaims, OwnershipClaim, Stack};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reconcile_ownership_simple() {
|
fn reconcile_ownership_simple() {
|
||||||
let mut branch_a = Branch::new(
|
let mut branch_a = Stack::new(
|
||||||
"a".to_string(),
|
"a".to_string(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -36,7 +36,7 @@ fn reconcile_ownership_simple() {
|
|||||||
branch_a.created_timestamp_ms = u128::default();
|
branch_a.created_timestamp_ms = u128::default();
|
||||||
branch_a.updated_timestamp_ms = u128::default();
|
branch_a.updated_timestamp_ms = u128::default();
|
||||||
|
|
||||||
let mut branch_b = Branch::new(
|
let mut branch_b = Stack::new(
|
||||||
"b".to_string(),
|
"b".to_string(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -60,7 +60,7 @@ fn reconcile_ownership_simple() {
|
|||||||
branch_b.created_timestamp_ms = u128::default();
|
branch_b.created_timestamp_ms = u128::default();
|
||||||
branch_b.updated_timestamp_ms = u128::default();
|
branch_b.updated_timestamp_ms = u128::default();
|
||||||
|
|
||||||
let all_branches: Vec<Branch> = vec![branch_a.clone(), branch_b.clone()];
|
let all_branches: Vec<Stack> = vec![branch_a.clone(), branch_b.clone()];
|
||||||
let claim: Vec<OwnershipClaim> = vec![OwnershipClaim {
|
let claim: Vec<OwnershipClaim> = vec![OwnershipClaim {
|
||||||
file_path: PathBuf::from("foo"),
|
file_path: PathBuf::from("foo"),
|
||||||
hunks: vec![
|
hunks: vec![
|
||||||
|
@ -7,7 +7,7 @@ use gitbutler_project as projects;
|
|||||||
use gitbutler_project::ProjectId;
|
use gitbutler_project::ProjectId;
|
||||||
use gitbutler_reference::RemoteRefname;
|
use gitbutler_reference::RemoteRefname;
|
||||||
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
||||||
use gitbutler_stack::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct App {
|
pub struct App {
|
||||||
@ -45,7 +45,7 @@ impl App {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
remote_name: &str,
|
remote_name: &str,
|
||||||
branch_name: &str,
|
branch_name: &str,
|
||||||
askpass: Option<Option<BranchId>>,
|
askpass: Option<Option<StackId>>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let project = self.projects().get(project_id)?;
|
let project = self.projects().get(project_id)?;
|
||||||
let ctx = CommandContext::open(&project)?;
|
let ctx = CommandContext::open(&project)?;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use gitbutler_branch_actions::stack::CreateSeriesRequest;
|
use gitbutler_branch_actions::stack::CreateSeriesRequest;
|
||||||
use gitbutler_project as projects;
|
use gitbutler_project as projects;
|
||||||
use gitbutler_project::ProjectId;
|
use gitbutler_project::ProjectId;
|
||||||
use gitbutler_stack::BranchId;
|
use gitbutler_stack::StackId;
|
||||||
use tauri::State;
|
use tauri::State;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ pub fn create_series(
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
request: CreateSeriesRequest,
|
request: CreateSeriesRequest,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
@ -29,7 +29,7 @@ pub fn remove_series(
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
head_name: String,
|
head_name: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
@ -44,7 +44,7 @@ pub fn update_series_name(
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
head_name: String,
|
head_name: String,
|
||||||
new_head_name: String,
|
new_head_name: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
@ -65,7 +65,7 @@ pub fn update_series_description(
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
head_name: String,
|
head_name: String,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
@ -86,7 +86,7 @@ pub fn push_stack(
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
|
@ -15,7 +15,7 @@ pub mod commands {
|
|||||||
use gitbutler_reference::{
|
use gitbutler_reference::{
|
||||||
normalize_branch_name as normalize_name, ReferenceName, Refname, RemoteRefname,
|
normalize_branch_name as normalize_name, ReferenceName, Refname, RemoteRefname,
|
||||||
};
|
};
|
||||||
use gitbutler_stack::{BranchId, BranchOwnershipClaims};
|
use gitbutler_stack::{BranchOwnershipClaims, StackId};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tauri::State;
|
use tauri::State;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
@ -34,7 +34,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: BranchId,
|
branch: StackId,
|
||||||
message: &str,
|
message: &str,
|
||||||
ownership: Option<BranchOwnershipClaims>,
|
ownership: Option<BranchOwnershipClaims>,
|
||||||
run_hooks: bool,
|
run_hooks: bool,
|
||||||
@ -73,7 +73,7 @@ pub mod commands {
|
|||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: BranchCreateRequest,
|
branch: BranchCreateRequest,
|
||||||
) -> Result<BranchId, Error> {
|
) -> Result<StackId, Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
let branch_id = gitbutler_branch_actions::create_virtual_branch(&project, &branch)?;
|
let branch_id = gitbutler_branch_actions::create_virtual_branch(&project, &branch)?;
|
||||||
emit_vbranches(&windows, project_id);
|
emit_vbranches(&windows, project_id);
|
||||||
@ -103,7 +103,7 @@ pub mod commands {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: Refname,
|
branch: Refname,
|
||||||
remote: Option<RemoteRefname>,
|
remote: Option<RemoteRefname>,
|
||||||
) -> Result<BranchId, Error> {
|
) -> Result<StackId, Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
let branch_id =
|
let branch_id =
|
||||||
gitbutler_branch_actions::create_virtual_branch_from_branch(&project, &branch, remote)?;
|
gitbutler_branch_actions::create_virtual_branch_from_branch(&project, &branch, remote)?;
|
||||||
@ -117,7 +117,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: BranchId,
|
branch: StackId,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
gitbutler_branch_actions::integrate_upstream_commits(&project, branch)?;
|
gitbutler_branch_actions::integrate_upstream_commits(&project, branch)?;
|
||||||
@ -224,7 +224,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
gitbutler_branch_actions::unapply_without_saving_virtual_branch(&project, branch_id)?;
|
gitbutler_branch_actions::unapply_without_saving_virtual_branch(&project, branch_id)?;
|
||||||
@ -238,7 +238,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: BranchId,
|
branch: StackId,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
gitbutler_branch_actions::save_and_unapply_virutal_branch(&project, branch)?;
|
gitbutler_branch_actions::save_and_unapply_virutal_branch(&project, branch)?;
|
||||||
@ -266,7 +266,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
files: Vec<PathBuf>,
|
files: Vec<PathBuf>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
@ -281,7 +281,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
) -> Result<PushResult, Error> {
|
) -> Result<PushResult, Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
@ -326,7 +326,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
target_commit_oid: String,
|
target_commit_oid: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
@ -342,7 +342,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: String,
|
commit_oid: String,
|
||||||
ownership: BranchOwnershipClaims,
|
ownership: BranchOwnershipClaims,
|
||||||
) -> Result<String, Error> {
|
) -> Result<String, Error> {
|
||||||
@ -359,7 +359,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
from_commit_oid: String,
|
from_commit_oid: String,
|
||||||
to_commit_oid: String,
|
to_commit_oid: String,
|
||||||
ownership: BranchOwnershipClaims,
|
ownership: BranchOwnershipClaims,
|
||||||
@ -384,7 +384,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: String,
|
commit_oid: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
@ -400,7 +400,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: String,
|
commit_oid: String,
|
||||||
offset: i32,
|
offset: i32,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
@ -417,7 +417,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: String,
|
commit_oid: String,
|
||||||
offset: i32,
|
offset: i32,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
@ -481,7 +481,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
target_commit_oid: String,
|
target_commit_oid: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
@ -531,7 +531,7 @@ pub mod commands {
|
|||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
commit_oid: String,
|
commit_oid: String,
|
||||||
target_branch_id: BranchId,
|
target_branch_id: StackId,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let project = projects.get(project_id)?;
|
let project = projects.get(project_id)?;
|
||||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||||
@ -546,7 +546,7 @@ pub mod commands {
|
|||||||
windows: State<'_, WindowState>,
|
windows: State<'_, WindowState>,
|
||||||
projects: State<'_, projects::Controller>,
|
projects: State<'_, projects::Controller>,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: StackId,
|
||||||
commit_oid: String,
|
commit_oid: String,
|
||||||
message: &str,
|
message: &str,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
Loading…
Reference in New Issue
Block a user