adapt to changes in gitbutler-branch crate

This commit is contained in:
Sebastian Thiel 2024-07-13 10:38:56 +02:00
parent 85b4e564cd
commit f48d0e2746
No known key found for this signature in database
GPG Key ID: 9CB5EE7895E8268B
39 changed files with 307 additions and 321 deletions

4
Cargo.lock generated
View File

@ -7195,9 +7195,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "uuid"
version = "1.9.1"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439"
checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314"
dependencies = [
"getrandom 0.2.15",
"rand 0.8.5",

View File

@ -1,8 +1,6 @@
use anyhow::Result;
use gitbutler_branch::{
branch::{BranchCreateRequest, BranchId, BranchUpdateRequest},
diff,
ownership::BranchOwnershipClaims,
diff, BranchOwnershipClaims, {BranchCreateRequest, BranchId, BranchUpdateRequest},
};
use gitbutler_command_context::ProjectRepository;
use gitbutler_oplog::{

View File

@ -2,11 +2,11 @@ use std::{path::Path, time};
use anyhow::{anyhow, Context, Result};
use git2::Index;
use gitbutler_branch::branch::{self, BranchId};
use gitbutler_branch::diff;
use gitbutler_branch::ownership::BranchOwnershipClaims;
use gitbutler_branch::target::Target;
use gitbutler_branch::BranchOwnershipClaims;
use gitbutler_branch::Target;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch::{self, BranchId};
use gitbutler_branch::{diff, Branch};
use gitbutler_command_context::ProjectRepository;
use gitbutler_project::FetchResult;
use gitbutler_reference::ReferenceName;
@ -234,7 +234,7 @@ pub(crate) fn set_base_branch(
(None, None)
};
let branch = branch::Branch {
let branch = Branch {
id: BranchId::generate(),
name: head_name.to_string().replace("refs/heads/", ""),
notes: String::new(),
@ -369,168 +369,161 @@ pub(crate) fn update_base_branch(
.0
.into_iter()
.map(|(branch, _)| branch)
.map(
|mut branch: branch::Branch| -> Result<Option<branch::Branch>> {
let branch_tree = repo.find_tree(branch.tree)?;
.map(|mut branch: Branch| -> Result<Option<Branch>> {
let branch_tree = repo.find_tree(branch.tree)?;
let branch_head_commit = repo.find_commit(branch.head).context(format!(
"failed to find commit {} for branch {}",
branch.head, branch.id
))?;
let branch_head_tree = branch_head_commit.tree().context(format!(
"failed to find tree for commit {} for branch {}",
branch.head, branch.id
let branch_head_commit = repo.find_commit(branch.head).context(format!(
"failed to find commit {} for branch {}",
branch.head, branch.id
))?;
let branch_head_tree = branch_head_commit.tree().context(format!(
"failed to find tree for commit {} for branch {}",
branch.head, branch.id
))?;
let result_integrated_detected = |mut branch: Branch| -> Result<Option<Branch>> {
// branch head tree is the same as the new target tree.
// meaning we can safely use the new target commit as the branch head.
branch.head = new_target_commit.id();
// it also means that the branch is fully integrated into the target.
// disconnect it from the upstream
branch.upstream = None;
branch.upstream_head = None;
let non_commited_files =
diff::trees(project_repository.repo(), &branch_head_tree, &branch_tree)?;
if non_commited_files.is_empty() {
// if there are no commited files, then the branch is fully merged
// and we can delete it.
vb_state.mark_as_not_in_workspace(branch.id)?;
project_repository.delete_branch_reference(&branch)?;
Ok(None)
} else {
vb_state.set_branch(branch.clone())?;
Ok(Some(branch))
}
};
if branch_head_tree.id() == new_target_tree.id() {
return result_integrated_detected(branch);
}
// try to merge branch head with new target
let mut branch_tree_merge_index = repo
.merge_trees(&old_target_tree, &branch_tree, &new_target_tree, None)
.context(format!("failed to merge trees for branch {}", branch.id))?;
if branch_tree_merge_index.has_conflicts() {
// branch tree conflicts with new target, unapply branch for now. we'll handle it later, when user applies it back.
let branch_manager = project_repository.branch_manager();
let unapplied_real_branch =
branch_manager.convert_to_real_branch(branch.id, Default::default())?;
unapplied_branch_names.push(unapplied_real_branch);
return Ok(None);
}
let branch_merge_index_tree_oid =
branch_tree_merge_index.write_tree_to(project_repository.repo())?;
if branch_merge_index_tree_oid == new_target_tree.id() {
return result_integrated_detected(branch);
}
if branch.head == target.sha {
// there are no commits on the branch, so we can just update the head to the new target and calculate the new tree
branch.head = new_target_commit.id();
branch.tree = branch_merge_index_tree_oid;
vb_state.set_branch(branch.clone())?;
return Ok(Some(branch));
}
let mut branch_head_merge_index = repo
.merge_trees(&old_target_tree, &branch_head_tree, &new_target_tree, None)
.context(format!(
"failed to merge head tree for branch {}",
branch.id
))?;
let result_integrated_detected =
|mut branch: branch::Branch| -> Result<Option<branch::Branch>> {
// branch head tree is the same as the new target tree.
// meaning we can safely use the new target commit as the branch head.
if branch_head_merge_index.has_conflicts() {
// branch commits conflict with new target, make sure the branch is
// unapplied. conflicts witll be dealt with when applying it back.
let branch_manager = project_repository.branch_manager();
let unapplied_real_branch =
branch_manager.convert_to_real_branch(branch.id, Default::default())?;
unapplied_branch_names.push(unapplied_real_branch);
branch.head = new_target_commit.id();
return Ok(None);
}
// it also means that the branch is fully integrated into the target.
// disconnect it from the upstream
branch.upstream = None;
branch.upstream_head = None;
// branch commits do not conflict with new target, so lets merge them
let branch_head_merge_tree_oid = branch_head_merge_index
.write_tree_to(project_repository.repo())
.context(format!(
"failed to write head merge index for {}",
branch.id
))?;
let non_commited_files = diff::trees(
project_repository.repo(),
&branch_head_tree,
&branch_tree,
)?;
if non_commited_files.is_empty() {
// if there are no commited files, then the branch is fully merged
// and we can delete it.
vb_state.mark_as_not_in_workspace(branch.id)?;
project_repository.delete_branch_reference(&branch)?;
Ok(None)
} else {
vb_state.set_branch(branch.clone())?;
Ok(Some(branch))
}
};
let ok_with_force_push = branch.allow_rebasing;
if branch_head_tree.id() == new_target_tree.id() {
return result_integrated_detected(branch);
}
let result_merge = |mut branch: Branch| -> Result<Option<Branch>> {
// branch was pushed to upstream, and user doesn't like force pushing.
// create a merge commit to avoid the need of force pushing then.
let branch_head_merge_tree = repo
.find_tree(branch_head_merge_tree_oid)
.context("failed to find tree")?;
// try to merge branch head with new target
let mut branch_tree_merge_index = repo
.merge_trees(&old_target_tree, &branch_tree, &new_target_tree, None)
.context(format!("failed to merge trees for branch {}", branch.id))?;
let new_target_head = project_repository
.commit(
format!(
"Merged {}/{} into {}",
target.branch.remote(),
target.branch.branch(),
branch.name,
)
.as_str(),
&branch_head_merge_tree,
&[&branch_head_commit, &new_target_commit],
None,
)
.context("failed to commit merge")?;
if branch_tree_merge_index.has_conflicts() {
// branch tree conflicts with new target, unapply branch for now. we'll handle it later, when user applies it back.
let branch_manager = project_repository.branch_manager();
let unapplied_real_branch =
branch_manager.convert_to_real_branch(branch.id, Default::default())?;
branch.head = new_target_head;
branch.tree = branch_merge_index_tree_oid;
vb_state.set_branch(branch.clone())?;
Ok(Some(branch))
};
unapplied_branch_names.push(unapplied_real_branch);
if branch.upstream.is_some() && !ok_with_force_push {
return result_merge(branch);
}
return Ok(None);
}
// branch was not pushed to upstream yet. attempt a rebase,
let rebased_head_oid = cherry_rebase(
project_repository,
new_target_commit.id(),
new_target_commit.id(),
branch.head,
);
let branch_merge_index_tree_oid =
branch_tree_merge_index.write_tree_to(project_repository.repo())?;
// rebase failed, just do the merge
if rebased_head_oid.is_err() {
return result_merge(branch);
}
if branch_merge_index_tree_oid == new_target_tree.id() {
return result_integrated_detected(branch);
}
if let Some(rebased_head_oid) = rebased_head_oid? {
// rebase worked out, rewrite the branch head
branch.head = rebased_head_oid;
branch.tree = branch_merge_index_tree_oid;
vb_state.set_branch(branch.clone())?;
return Ok(Some(branch));
}
if branch.head == target.sha {
// there are no commits on the branch, so we can just update the head to the new target and calculate the new tree
branch.head = new_target_commit.id();
branch.tree = branch_merge_index_tree_oid;
vb_state.set_branch(branch.clone())?;
return Ok(Some(branch));
}
let mut branch_head_merge_index = repo
.merge_trees(&old_target_tree, &branch_head_tree, &new_target_tree, None)
.context(format!(
"failed to merge head tree for branch {}",
branch.id
))?;
if branch_head_merge_index.has_conflicts() {
// branch commits conflict with new target, make sure the branch is
// unapplied. conflicts witll be dealt with when applying it back.
let branch_manager = project_repository.branch_manager();
let unapplied_real_branch =
branch_manager.convert_to_real_branch(branch.id, Default::default())?;
unapplied_branch_names.push(unapplied_real_branch);
return Ok(None);
}
// branch commits do not conflict with new target, so lets merge them
let branch_head_merge_tree_oid = branch_head_merge_index
.write_tree_to(project_repository.repo())
.context(format!(
"failed to write head merge index for {}",
branch.id
))?;
let ok_with_force_push = branch.allow_rebasing;
let result_merge =
|mut branch: branch::Branch| -> Result<Option<branch::Branch>> {
// branch was pushed to upstream, and user doesn't like force pushing.
// create a merge commit to avoid the need of force pushing then.
let branch_head_merge_tree = repo
.find_tree(branch_head_merge_tree_oid)
.context("failed to find tree")?;
let new_target_head = project_repository
.commit(
format!(
"Merged {}/{} into {}",
target.branch.remote(),
target.branch.branch(),
branch.name,
)
.as_str(),
&branch_head_merge_tree,
&[&branch_head_commit, &new_target_commit],
None,
)
.context("failed to commit merge")?;
branch.head = new_target_head;
branch.tree = branch_merge_index_tree_oid;
vb_state.set_branch(branch.clone())?;
Ok(Some(branch))
};
if branch.upstream.is_some() && !ok_with_force_push {
return result_merge(branch);
}
// branch was not pushed to upstream yet. attempt a rebase,
let rebased_head_oid = cherry_rebase(
project_repository,
new_target_commit.id(),
new_target_commit.id(),
branch.head,
);
// rebase failed, just do the merge
if rebased_head_oid.is_err() {
return result_merge(branch);
}
if let Some(rebased_head_oid) = rebased_head_oid? {
// rebase worked out, rewrite the branch head
branch.head = rebased_head_oid;
branch.tree = branch_merge_index_tree_oid;
vb_state.set_branch(branch.clone())?;
return Ok(Some(branch));
}
result_merge(branch)
},
)
result_merge(branch)
})
.collect::<Result<Vec<_>>>()?
.into_iter()
.flatten()

View File

@ -7,10 +7,7 @@ use crate::{
};
use anyhow::{anyhow, bail, Context, Result};
use gitbutler_branch::{
branch::{self, BranchCreateRequest, BranchId},
dedup::dedup,
diff,
ownership::BranchOwnershipClaims,
dedup, diff, Branch, BranchOwnershipClaims, {self, BranchCreateRequest, BranchId},
};
use gitbutler_commit::commit_headers::HasCommitHeaders;
use gitbutler_error::error::Marker;
@ -20,7 +17,7 @@ use gitbutler_repo::{rebase::cherry_rebase, RepoActions, RepositoryExt};
use gitbutler_time::time::now_since_unix_epoch_ms;
impl BranchManager<'_> {
pub fn create_virtual_branch(&self, create: &BranchCreateRequest) -> Result<branch::Branch> {
pub fn create_virtual_branch(&self, create: &BranchCreateRequest) -> Result<Branch> {
let vb_state = self.project_repository.project().virtual_branches();
let default_target = vb_state.get_default_target()?;
@ -91,7 +88,7 @@ impl BranchManager<'_> {
let now = gitbutler_time::time::now_ms();
let mut branch = branch::Branch {
let mut branch = Branch {
id: BranchId::generate(),
name: name.clone(),
notes: String::new(),
@ -170,7 +167,7 @@ impl BranchManager<'_> {
.list_branches_in_workspace()
.context("failed to read virtual branches")?
.into_iter()
.collect::<Vec<branch::Branch>>();
.collect::<Vec<Branch>>();
let order = vb_state.next_order_index()?;
@ -228,7 +225,7 @@ impl BranchManager<'_> {
branch
} else {
branch::Branch {
Branch {
id: BranchId::generate(),
name: branch_name.clone(),
notes: String::new(),

View File

@ -6,10 +6,7 @@ use crate::{
};
use anyhow::{anyhow, Context, Result};
use git2::build::TreeUpdateBuilder;
use gitbutler_branch::{
branch::{self, BranchId},
branch_ext::BranchExt,
};
use gitbutler_branch::{Branch, BranchExt, BranchId};
use gitbutler_commit::commit_headers::CommitHeadersV2;
use gitbutler_oplog::snapshot::Snapshot;
use gitbutler_reference::ReferenceName;
@ -124,7 +121,7 @@ impl BranchManager<'_> {
impl BranchManager<'_> {
fn build_real_branch(
&self,
vbranch: &mut branch::Branch,
vbranch: &mut Branch,
name_conflict_resolution: NameConflictResolution,
) -> Result<git2::Branch<'_>> {
let repo = self.project_repository.repo();
@ -179,7 +176,7 @@ impl BranchManager<'_> {
fn build_metadata_commit(
&self,
vbranch: &mut branch::Branch,
vbranch: &mut Branch,
branch: &git2::Branch<'_>,
) -> Result<git2::Oid> {
let repo = self.project_repository.repo();

View File

@ -3,8 +3,8 @@ use std::{path::PathBuf, vec};
use anyhow::{anyhow, bail, Context, Result};
use bstr::ByteSlice;
use gitbutler_branch::branch::{self, BranchCreateRequest};
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch::{self, BranchCreateRequest};
use gitbutler_branch::{Branch, VirtualBranchesHandle};
use gitbutler_branch::{
GITBUTLER_INTEGRATION_COMMIT_AUTHOR_EMAIL, GITBUTLER_INTEGRATION_COMMIT_AUTHOR_NAME,
GITBUTLER_INTEGRATION_REFERENCE,
@ -40,7 +40,7 @@ pub(crate) fn get_workspace_head(
let repo: &git2::Repository = project_repo.repo();
let vb_state = project_repo.project().virtual_branches();
let virtual_branches: Vec<branch::Branch> = vb_state.list_branches_in_workspace()?;
let virtual_branches: Vec<Branch> = vb_state.list_branches_in_workspace()?;
let target_commit = repo.find_commit(target.sha)?;
let mut workspace_tree = target_commit.tree()?;
@ -166,7 +166,7 @@ pub fn update_gitbutler_integration(
let vb_state = project_repository.project().virtual_branches();
// get all virtual branches, we need to try to update them all
let virtual_branches: Vec<branch::Branch> = vb_state
let virtual_branches: Vec<Branch> = vb_state
.list_branches_in_workspace()
.context("failed to list virtual branches")?;

View File

@ -2,15 +2,13 @@ use std::path::Path;
use anyhow::{Context, Result};
use bstr::BString;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch::{Target, VirtualBranchesHandle};
use gitbutler_command_context::ProjectRepository;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_reference::{Refname, RemoteRefname};
use gitbutler_repo::{LogUntil, RepoActions, RepositoryExt};
use serde::Serialize;
use gitbutler_branch::target;
use crate::author::Author;
// this struct is a mapping to the view `RemoteBranch` type in Typescript
@ -198,6 +196,6 @@ pub(crate) fn commit_to_remote_commit(commit: &git2::Commit) -> RemoteCommit {
}
}
fn default_target(base_path: &Path) -> Result<target::Target> {
fn default_target(base_path: &Path) -> Result<Target> {
VirtualBranchesHandle::new(base_path).get_default_target()
}

View File

@ -1,10 +1,9 @@
use gitbutler_branch::branch::{self, Branch, BranchCreateRequest, BranchId};
use gitbutler_branch::dedup::{dedup, dedup_fmt};
use gitbutler_branch::diff::{self, diff_files_into_hunks, trees, FileDiff, GitHunk};
use gitbutler_branch::file_ownership::OwnershipClaim;
use gitbutler_branch::hunk::{Hunk, HunkHash};
use gitbutler_branch::ownership::{reconcile_claims, BranchOwnershipClaims};
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch::{dedup, BranchUpdateRequest, VirtualBranchesHandle};
use gitbutler_branch::{dedup_fmt, Branch, BranchCreateRequest, BranchId};
use gitbutler_branch::{reconcile_claims, BranchOwnershipClaims};
use gitbutler_branch::{Hunk, HunkHash};
use gitbutler_branch::{OwnershipClaim, Target};
use gitbutler_command_context::ProjectRepository;
use gitbutler_commit::commit_ext::CommitExt;
use gitbutler_commit::commit_headers::HasCommitHeaders;
@ -34,13 +33,12 @@ use crate::conflicts::{self, RepoConflictsExt};
use crate::integration::get_workspace_head;
use crate::remote::{branch_to_remote_branch, RemoteBranch};
use crate::VirtualBranchesExt;
use gitbutler_branch::target;
use gitbutler_error::error::Code;
use gitbutler_error::error::Marker;
use gitbutler_repo::rebase::{cherry_rebase, cherry_rebase_group};
use gitbutler_time::time::now_since_unix_epoch_ms;
type AppliedStatuses = Vec<(branch::Branch, BranchStatus)>;
type AppliedStatuses = Vec<(Branch, BranchStatus)>;
// this struct is a mapping to the view `Branch` type in Typescript
// found in src-tauri/src/routes/repo/[project_id]/types.ts
@ -543,10 +541,7 @@ fn joined(start_a: u32, end_a: u32, start_b: u32, end_b: u32) -> bool {
|| ((start_b >= start_a && start_b <= end_a) || (end_b >= start_a && end_b <= end_a))
}
fn is_requires_force(
project_repository: &ProjectRepository,
branch: &branch::Branch,
) -> Result<bool> {
fn is_requires_force(project_repository: &ProjectRepository, branch: &Branch) -> Result<bool> {
let upstream = if let Some(upstream) = &branch.upstream {
upstream
} else {
@ -594,7 +589,7 @@ fn list_virtual_commit_files(
fn commit_to_vbranch_commit(
repository: &ProjectRepository,
branch: &branch::Branch,
branch: &Branch,
commit: &git2::Commit,
is_integrated: bool,
is_remote: bool,
@ -853,8 +848,8 @@ pub(crate) fn integrate_with_merge(
pub fn update_branch(
project_repository: &ProjectRepository,
branch_update: &branch::BranchUpdateRequest,
) -> Result<branch::Branch> {
branch_update: &BranchUpdateRequest,
) -> Result<Branch> {
let vb_state = project_repository.project().virtual_branches();
let mut branch = vb_state.get_branch_in_workspace(branch_update.id)?;
@ -957,8 +952,8 @@ pub(crate) fn ensure_selected_for_changes(vb_state: &VirtualBranchesHandle) -> R
pub(crate) fn set_ownership(
vb_state: &VirtualBranchesHandle,
target_branch: &mut branch::Branch,
ownership: &gitbutler_branch::ownership::BranchOwnershipClaims,
target_branch: &mut Branch,
ownership: &BranchOwnershipClaims,
) -> Result<()> {
if target_branch.ownership.eq(ownership) {
// nothing to update
@ -1071,7 +1066,7 @@ pub fn get_status_by_branch(
fn new_compute_locks(
repository: &git2::Repository,
unstaged_hunks_by_path: &HashMap<PathBuf, Vec<diff::GitHunk>>,
virtual_branches: &[branch::Branch],
virtual_branches: &[Branch],
) -> Result<HashMap<HunkHash, Vec<diff::HunkLock>>> {
// If we cant find the integration commit and subsequently the target commit, we can't find any locks
let target_tree = repository.target_commit()?.tree()?;
@ -1096,8 +1091,7 @@ fn new_compute_locks(
})
.collect::<Vec<_>>();
let mut integration_hunks_by_path =
HashMap::<PathBuf, Vec<(diff::GitHunk, &branch::Branch)>>::new();
let mut integration_hunks_by_path = HashMap::<PathBuf, Vec<(diff::GitHunk, &Branch)>>::new();
for (branch, hunks_by_filepath) in branch_path_diffs {
for (path, hunks) in hunks_by_filepath {
@ -1146,7 +1140,7 @@ fn new_compute_locks(
pub(crate) fn get_applied_status(
project_repository: &ProjectRepository,
integration_commit: &git2::Oid,
mut virtual_branches: Vec<branch::Branch>,
mut virtual_branches: Vec<Branch>,
) -> Result<(AppliedStatuses, Vec<diff::FileDiff>)> {
let base_file_diffs = diff::workdir(project_repository.repo(), &integration_commit.to_owned())
.context("failed to diff workdir")?;
@ -1601,7 +1595,7 @@ pub fn commit(
project_repository: &ProjectRepository,
branch_id: BranchId,
message: &str,
ownership: Option<&gitbutler_branch::ownership::BranchOwnershipClaims>,
ownership: Option<&BranchOwnershipClaims>,
run_hooks: bool,
) -> Result<git2::Oid> {
let mut message_buffer = message.to_owned();
@ -1787,7 +1781,7 @@ pub(crate) fn push(
fn is_commit_integrated(
project_repository: &ProjectRepository,
target: &target::Target,
target: &Target,
commit: &git2::Commit,
) -> Result<bool> {
let remote_branch = project_repository

View File

@ -14,9 +14,7 @@ use anyhow::{Context, Result};
use git2::TreeEntry;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch::{
branch::{BranchCreateRequest, BranchUpdateRequest},
ownership::BranchOwnershipClaims,
target::Target,
BranchOwnershipClaims, Target, {BranchCreateRequest, BranchUpdateRequest},
};
use gitbutler_branch_actions::BranchManagerExt;
use gitbutler_branch_actions::{

View File

@ -1,4 +1,5 @@
use gitbutler_branch::ownership::BranchOwnershipClaims;
use gitbutler_branch::BranchOwnershipClaims;
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
use super::*;
@ -35,7 +36,7 @@ async fn forcepush_allowed() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -90,14 +91,14 @@ async fn forcepush_forbidden() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch_id,
allow_rebasing: Some(false),
..Default::default()
@ -147,7 +148,7 @@ async fn non_locked_hunk() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -208,7 +209,7 @@ async fn locked_hunk() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -278,7 +279,7 @@ async fn non_existing_ownership() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,3 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_reference::Refname;
use super::*;
@ -30,7 +31,7 @@ async fn rebase_commit() {
let mut branch1_id = {
// create a branch with some commited work
let branch1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
fs::write(repository.path().join("another_file.txt"), "virtual").unwrap();
@ -145,7 +146,7 @@ async fn rebase_work() {
let mut branch1_id = {
// make a branch with some work
let branch1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
fs::write(repository.path().join("another_file.txt"), "").unwrap();

View File

@ -1,3 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_reference::Refname;
use super::*;
@ -142,7 +143,7 @@ async fn delete_if_empty() {
.unwrap();
controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,4 +1,4 @@
use gitbutler_branch::branch::Branch;
use gitbutler_branch::{Branch, BranchCreateRequest, BranchUpdateRequest};
use gitbutler_branch_actions::VirtualBranch;
use gitbutler_id::id::Id;
@ -19,7 +19,7 @@ async fn should_lock_updated_hunks() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -76,14 +76,14 @@ async fn should_reset_into_same_branch() {
.unwrap();
controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
let branch_2_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
selected_for_changes: Some(true),
..Default::default()
},
@ -108,7 +108,7 @@ async fn should_reset_into_same_branch() {
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch_2_id,
selected_for_changes: Some(true),
..Default::default()

View File

@ -1,3 +1,4 @@
use gitbutler_branch::BranchCreateRequest;
use gitbutler_reference::LocalRefname;
use super::*;
@ -20,7 +21,7 @@ async fn integration() {
// make a remote branch
let branch_id = controller
.create_virtual_branch(project, &super::branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,4 +1,5 @@
use super::*;
use gitbutler_branch::BranchCreateRequest;
#[tokio::test]
async fn should_unapply_diff() {
@ -53,7 +54,7 @@ async fn should_remove_reference() {
let id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
name: Some("name".to_string()),
..Default::default()
},

View File

@ -1,4 +1,5 @@
use super::*;
use gitbutler_branch::BranchCreateRequest;
#[tokio::test]
async fn insert_blank_commit_down() {
@ -15,7 +16,7 @@ async fn insert_blank_commit_down() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -87,7 +88,7 @@ async fn insert_blank_commit_up() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,14 +1,13 @@
use std::path::PathBuf;
use std::{fs, path, str::FromStr};
use gitbutler_branch::branch;
use gitbutler_branch::BranchCreateRequest;
use gitbutler_branch_actions::VirtualBranchActions;
use gitbutler_error::error::Marker;
use gitbutler_project::{self as projects, Project, ProjectId};
use gitbutler_reference::Refname;
use tempfile::TempDir;
use gitbutler_testsupport::{paths, TestProject, VAR_NO_CLEANUP};
use tempfile::TempDir;
struct Test {
repository: TestProject,
@ -111,7 +110,7 @@ async fn resolve_conflict_flow() {
{
// make a branch that conflicts with the remote branch, but doesn't know about it yet
let branch1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
fs::write(repository.path().join("file.txt"), "conflict").unwrap();

View File

@ -1,4 +1,5 @@
use gitbutler_branch::ownership::BranchOwnershipClaims;
use gitbutler_branch::BranchCreateRequest;
use gitbutler_branch::BranchOwnershipClaims;
use gitbutler_commit::commit_ext::CommitExt;
use super::*;
@ -18,7 +19,7 @@ async fn move_file_down() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -82,7 +83,7 @@ async fn move_file_up() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -141,7 +142,7 @@ async fn move_file_up_overlapping_hunks() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -180,7 +181,7 @@ async fn move_file_up_overlapping_hunks() {
.unwrap();
// move one line from middle commit two up to middle commit one
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-6".parse().unwrap();
let to_amend: BranchOwnershipClaims = "file2.txt:1-6".parse().unwrap();
controller
.move_commit_file(project, branch_id, commit2_id, commit3_id, &to_amend)
.await

View File

@ -1,4 +1,4 @@
use gitbutler_branch::branch::{BranchCreateRequest, BranchId};
use gitbutler_branch::{BranchCreateRequest, BranchId};
use super::Test;

View File

@ -1,5 +1,5 @@
use super::*;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch::{BranchCreateRequest, VirtualBranchesHandle};
use gitbutler_oplog::oplog::Oplog;
use itertools::Itertools;
use std::io::Write;
@ -31,7 +31,7 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
let branch_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
name: Some(round.to_string()),
..Default::default()
},
@ -113,7 +113,7 @@ async fn basic_oplog() -> anyhow::Result<()> {
.await?;
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await?;
// create commit
@ -146,7 +146,7 @@ async fn basic_oplog() -> anyhow::Result<()> {
// create state with conflict state
let _empty_branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await?;
std::fs::remove_file(&base_merge_parent_path)?;
@ -268,7 +268,7 @@ async fn restores_gitbutler_integration() -> anyhow::Result<()> {
0
);
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await?;
assert_eq!(
VirtualBranchesHandle::new(project.gb_dir())

View File

@ -1,9 +1,8 @@
use super::*;
mod create_virtual_branch {
use branch::BranchCreateRequest;
use super::*;
use gitbutler_branch::BranchCreateRequest;
#[tokio::test]
async fn simple() {
@ -20,7 +19,7 @@ mod create_virtual_branch {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -92,6 +91,7 @@ mod create_virtual_branch {
mod update_virtual_branch {
use super::*;
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
#[tokio::test]
async fn simple() {
@ -110,7 +110,7 @@ mod update_virtual_branch {
let branch_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
name: Some("name".to_string()),
..Default::default()
},
@ -121,7 +121,7 @@ mod update_virtual_branch {
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch_id,
name: Some("new name".to_string()),
..Default::default()
@ -161,7 +161,7 @@ mod update_virtual_branch {
let branch1_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
name: Some("name".to_string()),
..Default::default()
},
@ -172,7 +172,7 @@ mod update_virtual_branch {
let branch2_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
..Default::default()
},
)
@ -182,7 +182,7 @@ mod update_virtual_branch {
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch2_id,
name: Some("name".to_string()),
..Default::default()
@ -209,8 +209,8 @@ mod update_virtual_branch {
}
mod push_virtual_branch {
use super::*;
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
#[tokio::test]
async fn simple() {
@ -229,7 +229,7 @@ mod push_virtual_branch {
let branch1_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
name: Some("name".to_string()),
..Default::default()
},
@ -284,7 +284,7 @@ mod push_virtual_branch {
let branch1_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
name: Some("name".to_string()),
..Default::default()
},
@ -307,7 +307,7 @@ mod push_virtual_branch {
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch1_id,
name: Some("updated name".to_string()),
..Default::default()
@ -321,7 +321,7 @@ mod push_virtual_branch {
let branch2_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
name: Some("name".to_string()),
..Default::default()
},

View File

@ -1,4 +1,5 @@
use super::*;
use gitbutler_branch::BranchCreateRequest;
#[tokio::test]
async fn reorder_commit_down() {
@ -15,7 +16,7 @@ async fn reorder_commit_down() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -76,7 +77,7 @@ async fn reorder_commit_up() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

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

View File

@ -1,4 +1,5 @@
use super::*;
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
#[tokio::test]
async fn unapplying_selected_branch_selects_anther() {
@ -18,13 +19,13 @@ async fn unapplying_selected_branch_selects_anther() {
// first branch should be created as default
let b_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
// if default branch exists, new branch should not be created as default
let b2_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -65,13 +66,13 @@ async fn deleting_selected_branch_selects_anther() {
// first branch should be created as default
let b_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
// if default branch exists, new branch should not be created as default
let b2_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -111,7 +112,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
// first branch should be created as default
let b_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
let branch = controller
@ -126,7 +127,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
// if default branch exists, new branch should not be created as default
let b_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
let branch = controller
@ -143,7 +144,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
let b_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
selected_for_changes: Some(false),
..Default::default()
},
@ -164,7 +165,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
let b_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
selected_for_changes: Some(true),
..Default::default()
},
@ -196,7 +197,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
.unwrap();
let b1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
let b1 = controller
@ -210,7 +211,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
assert!(b1.selected_for_changes);
let b2_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
let b2 = controller
@ -226,7 +227,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: b2_id,
selected_for_changes: Some(true),
..Default::default()
@ -271,7 +272,7 @@ async fn unapply_virtual_branch_should_reset_selected_for_changes() {
.unwrap();
let b1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
@ -287,7 +288,7 @@ async fn unapply_virtual_branch_should_reset_selected_for_changes() {
assert!(b1.selected_for_changes);
let b2_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -337,7 +338,7 @@ async fn hunks_distribution() {
controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
selected_for_changes: Some(true),
..Default::default()
},
@ -423,7 +424,7 @@ async fn new_locked_hunk_without_modifying_existing() {
controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
selected_for_changes: Some(true),
..Default::default()
},

View File

@ -42,9 +42,9 @@ mod error {
}
mod go_back_to_integration {
use pretty_assertions::assert_eq;
use super::*;
use gitbutler_branch::BranchCreateRequest;
use pretty_assertions::assert_eq;
#[tokio::test]
async fn should_preserve_applied_vbranches() {
@ -67,7 +67,7 @@ mod go_back_to_integration {
.unwrap();
let vbranch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,4 +1,5 @@
use super::*;
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
#[tokio::test]
async fn head() {
@ -15,7 +16,7 @@ async fn head() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -91,7 +92,7 @@ async fn middle() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -177,7 +178,7 @@ async fn forcepush_allowed() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -259,14 +260,14 @@ async fn forcepush_forbidden() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch_id,
allow_rebasing: Some(false),
..Default::default()
@ -337,7 +338,7 @@ async fn root_forbidden() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

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

View File

@ -1,4 +1,5 @@
use super::*;
use gitbutler_branch::BranchCreateRequest;
#[tokio::test]
async fn undo_commit_simple() {
@ -15,7 +16,7 @@ async fn undo_commit_simple() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,8 +1,8 @@
use super::*;
mod applied_branch {
use super::*;
use gitbutler_branch::BranchCreateRequest;
#[tokio::test]
async fn conflicts_with_uncommitted_work() {
@ -31,7 +31,7 @@ mod applied_branch {
{
// make a branch that conflicts with the remote branch, but doesn't know about it yet
controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -97,7 +97,7 @@ mod applied_branch {
// make a branch with a commit that conflicts with upstream, and work that fixes
// that conflict
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -168,7 +168,7 @@ mod applied_branch {
// make a branch with a commit that conflicts with upstream, and work that fixes
// that conflict
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -244,7 +244,7 @@ mod applied_branch {
// make a branch with a commit that conflicts with upstream, and work that fixes
// that conflict
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -317,7 +317,7 @@ mod applied_branch {
// make a branch with a commit that conflicts with upstream, and work that fixes
// that conflict
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -364,6 +364,7 @@ mod applied_branch {
mod no_conflicts_pushed {
use super::*;
use gitbutler_branch::BranchUpdateRequest;
#[tokio::test]
async fn force_push_ok() {
@ -401,7 +402,7 @@ mod applied_branch {
let branch_id = {
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -467,7 +468,7 @@ mod applied_branch {
let branch_id = {
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -490,7 +491,7 @@ mod applied_branch {
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch_id,
allow_rebasing: Some(false),
..Default::default()
@ -547,7 +548,7 @@ mod applied_branch {
let branch_id = {
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -611,7 +612,7 @@ mod applied_branch {
let branch_id = {
// make a branch that conflicts with the remote branch, but doesn't know about it yet
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -706,7 +707,7 @@ mod applied_branch {
// branch has no conflict
let branch_id = {
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -810,7 +811,7 @@ mod applied_branch {
let branch_id = {
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -872,7 +873,7 @@ mod applied_branch {
let branch_id = {
// make a branch that conflicts with the remote branch, but doesn't know about it yet
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -944,7 +945,7 @@ mod applied_branch {
{
// make a branch that conflicts with the remote branch, but doesn't know about it yet
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -992,7 +993,7 @@ mod applied_branch {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -1050,7 +1051,7 @@ mod applied_branch {
.unwrap();
let branch_1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -1063,7 +1064,7 @@ mod applied_branch {
let branch_2_id = controller
.create_virtual_branch(
project,
&branch::BranchCreateRequest {
&BranchCreateRequest {
selected_for_changes: Some(true),
..Default::default()
},

View File

@ -1,3 +1,4 @@
use gitbutler_branch::{BranchCreateRequest, BranchUpdateRequest};
use gitbutler_commit::commit_ext::CommitExt;
use super::*;
@ -17,7 +18,7 @@ async fn head() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -95,7 +96,7 @@ async fn middle() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -173,7 +174,7 @@ async fn forcepush_allowed() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -228,14 +229,14 @@ async fn forcepush_forbidden() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
controller
.update_virtual_branch(
project,
branch::BranchUpdateRequest {
BranchUpdateRequest {
id: branch_id,
allow_rebasing: Some(false),
..Default::default()
@ -282,7 +283,7 @@ async fn root() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -350,7 +351,7 @@ async fn empty() {
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,4 +1,5 @@
use super::*;
use gitbutler_branch::BranchCreateRequest;
#[tokio::test]
async fn detect_upstream_commits() {
@ -15,7 +16,7 @@ async fn detect_upstream_commits() {
.unwrap();
let branch1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();
@ -82,7 +83,7 @@ async fn detect_integrated_commits() {
.unwrap();
let branch1_id = controller
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
.create_virtual_branch(project, &BranchCreateRequest::default())
.await
.unwrap();

View File

@ -1,8 +1,7 @@
use anyhow::{anyhow, bail, Context};
use git2::{DiffOptions, FileMode};
use gitbutler_branch::branch::Branch;
use gitbutler_branch::diff::{hunks_by_filepath, FileDiff};
use gitbutler_branch::{VirtualBranchesHandle, VirtualBranchesState};
use gitbutler_branch::{Branch, VirtualBranchesHandle, VirtualBranchesState};
use gitbutler_project::Project;
use gitbutler_repo::RepositoryExt;
use std::collections::HashMap;

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use gitbutler_branch::branch::{Branch, BranchUpdateRequest};
use gitbutler_branch::{Branch, BranchUpdateRequest};
use gitbutler_project::Project;
use gitbutler_reference::ReferenceName;
use std::vec;

View File

@ -1,11 +1,10 @@
use std::{collections::HashMap, path::Path, sync::Arc};
use gitbutler_branch::branch::BranchId;
use gitbutler_branch::BranchId;
use gitbutler_id::id::Id;
use serde::Serialize;
use tokio::sync::{oneshot, Mutex};
use gitbutler_id::id::Id;
static mut GLOBAL_ASKPASS_BROKER: Option<AskpassBroker> = None;
/// Initialize the global askpass broker.

View File

@ -2,7 +2,7 @@ use std::str::FromStr;
use anyhow::{anyhow, Context, Result};
use gitbutler_branch::branch::{Branch, BranchId};
use gitbutler_branch::{Branch, BranchId};
use gitbutler_command_context::ProjectRepository;
use gitbutler_commit::commit_headers::CommitHeadersV2;
use gitbutler_error::error::Code;

View File

@ -3,7 +3,7 @@ use std::sync::Arc;
use std::time;
use anyhow::{anyhow, Context, Result};
use gitbutler_branch::target::Target;
use gitbutler_branch::Target;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_command_context::ProjectRepository;
use gitbutler_error::error::Code;

View File

@ -1,5 +1,5 @@
use anyhow::{Context, Result};
use gitbutler_branch::branch::BranchId;
use gitbutler_branch::BranchId;
use gitbutler_branch_actions::conflicts;
use gitbutler_command_context::ProjectRepository;
use gitbutler_project as projects;

View File

@ -1,8 +1,8 @@
pub mod commands {
use crate::error::Error;
use anyhow::{anyhow, Context};
use gitbutler_branch::branch::{BranchCreateRequest, BranchId, BranchUpdateRequest};
use gitbutler_branch::ownership::BranchOwnershipClaims;
use gitbutler_branch::BranchOwnershipClaims;
use gitbutler_branch::{BranchCreateRequest, BranchId, BranchUpdateRequest};
use gitbutler_branch_actions::BaseBranch;
use gitbutler_branch_actions::RemoteBranchFile;
use gitbutler_branch_actions::{NameConflictResolution, VirtualBranchActions, VirtualBranches};

View File

@ -18,7 +18,7 @@ pub mod paths {
}
pub mod virtual_branches {
use gitbutler_branch::target::Target;
use gitbutler_branch::Target;
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_command_context::ProjectRepository;