mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-08-17 08:10:52 +03:00
Merge pull request #4243 from gitbutlerapp/simplify-virtual-branches-controller-deps-graph
simplify virtual branches controller deps graph
This commit is contained in:
commit
ec52598f62
@ -16,7 +16,7 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
git, project_repository,
|
||||
projects::{self, ProjectId},
|
||||
projects::{self, Project},
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -39,14 +39,14 @@ impl Controller {
|
||||
|
||||
pub async fn create_commit(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
message: &str,
|
||||
ownership: Option<&BranchOwnershipClaims>,
|
||||
run_hooks: bool,
|
||||
) -> Result<git2::Oid> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let result =
|
||||
super::commit(project_repository, branch_id, message, ownership, run_hooks)
|
||||
@ -65,33 +65,32 @@ impl Controller {
|
||||
|
||||
pub async fn can_apply_remote_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_name: &git::RemoteRefname,
|
||||
) -> Result<bool> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
super::is_remote_branch_mergeable(&project_repository, branch_name).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub async fn list_virtual_branches(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
) -> Result<(Vec<super::VirtualBranch>, Vec<git::diff::FileDiff>)> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
super::list_virtual_branches(project_repository).map_err(Into::into)
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn create_virtual_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
create: &super::branch::BranchCreateRequest,
|
||||
) -> Result<BranchId> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let branch_id = super::create_virtual_branch(project_repository, create)?.id;
|
||||
Ok(branch_id)
|
||||
})
|
||||
@ -99,63 +98,55 @@ impl Controller {
|
||||
|
||||
pub async fn create_virtual_branch_from_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch: &git::Refname,
|
||||
) -> Result<BranchId> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
super::create_virtual_branch_from_branch(project_repository, branch).map_err(Into::into)
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn get_base_branch_data(&self, project_id: ProjectId) -> Result<BaseBranch> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
pub async fn get_base_branch_data(&self, project: &Project) -> Result<BaseBranch> {
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
super::get_base_branch_data(&project_repository)
|
||||
}
|
||||
|
||||
pub async fn list_remote_commit_files(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<Vec<RemoteBranchFile>> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
super::list_remote_commit_files(project_repository.repo(), commit_oid).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub async fn set_base_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
target_branch: &git::RemoteRefname,
|
||||
) -> Result<BaseBranch> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::SetBaseBranch));
|
||||
super::set_base_branch(&project_repository, target_branch)
|
||||
}
|
||||
|
||||
pub async fn set_target_push_remote(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
push_remote: &str,
|
||||
) -> Result<()> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
pub async fn set_target_push_remote(&self, project: &Project, push_remote: &str) -> Result<()> {
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
super::set_target_push_remote(&project_repository, push_remote)
|
||||
}
|
||||
|
||||
pub async fn integrate_upstream_commits(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::MergeUpstream));
|
||||
@ -163,10 +154,10 @@ impl Controller {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn update_base_branch(&self, project_id: ProjectId) -> Result<Vec<ReferenceName>> {
|
||||
pub async fn update_base_branch(&self, project: &Project) -> Result<Vec<ReferenceName>> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::UpdateWorkspaceBase));
|
||||
@ -183,12 +174,12 @@ impl Controller {
|
||||
|
||||
pub async fn update_virtual_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_update: super::branch::BranchUpdateRequest,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let old_branch = project_repository
|
||||
.project()
|
||||
@ -210,24 +201,24 @@ impl Controller {
|
||||
}
|
||||
pub async fn delete_virtual_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
super::delete_branch(project_repository, branch_id)
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn unapply_ownership(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::DiscardHunk));
|
||||
@ -235,10 +226,10 @@ impl Controller {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn reset_files(&self, project_id: ProjectId, files: &Vec<String>) -> Result<()> {
|
||||
pub async fn reset_files(&self, project: &Project, files: &Vec<String>) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::DiscardFile));
|
||||
@ -248,14 +239,14 @@ impl Controller {
|
||||
|
||||
pub async fn amend(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<git2::Oid> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::AmendCommit));
|
||||
@ -265,7 +256,7 @@ impl Controller {
|
||||
|
||||
pub async fn move_commit_file(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
from_commit_oid: git2::Oid,
|
||||
to_commit_oid: git2::Oid,
|
||||
@ -273,7 +264,7 @@ impl Controller {
|
||||
) -> Result<git2::Oid> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::MoveCommitFile));
|
||||
@ -290,13 +281,13 @@ impl Controller {
|
||||
|
||||
pub async fn undo_commit(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let result: Result<()> =
|
||||
super::undo_commit(project_repository, branch_id, commit_oid).map_err(Into::into);
|
||||
@ -313,14 +304,14 @@ impl Controller {
|
||||
|
||||
pub async fn insert_blank_commit(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
offset: i32,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::InsertBlankCommit));
|
||||
@ -331,14 +322,14 @@ impl Controller {
|
||||
|
||||
pub async fn reorder_commit(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
offset: i32,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::ReorderCommit));
|
||||
@ -349,13 +340,13 @@ impl Controller {
|
||||
|
||||
pub async fn reset_virtual_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::UndoCommit));
|
||||
@ -366,13 +357,13 @@ impl Controller {
|
||||
|
||||
pub async fn convert_to_real_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
name_conflict_resolution: NameConflitResolution,
|
||||
) -> Result<ReferenceName> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let snapshot_tree = project_repository.project().prepare_snapshot();
|
||||
let result = super::convert_to_real_branch(
|
||||
project_repository,
|
||||
@ -391,47 +382,42 @@ impl Controller {
|
||||
|
||||
pub async fn push_virtual_branch(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
with_force: bool,
|
||||
askpass: Option<Option<BranchId>>,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
let helper = self.helper.clone();
|
||||
self.with_verify_branch_async(project_id, move |project_repository| {
|
||||
self.with_verify_branch_async(project, move |project_repository| {
|
||||
super::push(project_repository, branch_id, with_force, &helper, askpass)
|
||||
})?
|
||||
.await?
|
||||
}
|
||||
|
||||
pub async fn list_remote_branches(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<super::RemoteBranch>> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
pub async fn list_remote_branches(&self, project: Project) -> Result<Vec<super::RemoteBranch>> {
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
super::list_remote_branches(&project_repository)
|
||||
}
|
||||
|
||||
pub async fn get_remote_branch_data(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
refname: &git::Refname,
|
||||
) -> Result<super::RemoteBranchData> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
super::get_branch_data(&project_repository, refname)
|
||||
}
|
||||
|
||||
pub async fn squash(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::SquashCommit));
|
||||
@ -441,13 +427,13 @@ impl Controller {
|
||||
|
||||
pub async fn update_commit_message(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
message: &str,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::UpdateCommitMessage));
|
||||
@ -458,11 +444,10 @@ impl Controller {
|
||||
|
||||
pub async fn fetch_from_remotes(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
askpass: Option<String>,
|
||||
) -> Result<BaseBranch> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let mut project_repository = project_repository::Repository::open(&project)?;
|
||||
let mut project_repository = project_repository::Repository::open(project)?;
|
||||
|
||||
let remotes = project_repository.remotes()?;
|
||||
let fetch_results: Vec<Result<(), _>> = remotes
|
||||
@ -500,7 +485,7 @@ impl Controller {
|
||||
let updated_project = self
|
||||
.projects
|
||||
.update(&projects::UpdateRequest {
|
||||
id: project_id,
|
||||
id: project.id,
|
||||
project_data_last_fetched: Some(project_data_last_fetched),
|
||||
..Default::default()
|
||||
})
|
||||
@ -517,13 +502,13 @@ impl Controller {
|
||||
|
||||
pub async fn move_commit(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
target_branch_id: BranchId,
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<()> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository| {
|
||||
self.with_verify_branch(project, |project_repository| {
|
||||
let _ = project_repository
|
||||
.project()
|
||||
.create_snapshot(SnapshotDetails::new(OperationKind::MoveCommit));
|
||||
@ -535,22 +520,20 @@ impl Controller {
|
||||
impl Controller {
|
||||
fn with_verify_branch<T>(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
action: impl FnOnce(&project_repository::Repository) -> Result<T>,
|
||||
) -> Result<T> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
super::integration::verify_branch(&project_repository)?;
|
||||
action(&project_repository)
|
||||
}
|
||||
|
||||
fn with_verify_branch_async<T: Send + 'static>(
|
||||
&self,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
action: impl FnOnce(&project_repository::Repository) -> Result<T> + Send + 'static,
|
||||
) -> Result<JoinHandle<Result<T>>> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let project_repository = project_repository::Repository::open(project)?;
|
||||
super::integration::verify_branch(&project_repository)?;
|
||||
Ok(tokio::task::spawn_blocking(move || {
|
||||
action(&project_repository)
|
||||
|
@ -5,6 +5,7 @@ async fn forcepush_allowed() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
projects,
|
||||
..
|
||||
@ -19,7 +20,7 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -32,19 +33,19 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let commit_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -53,12 +54,12 @@ async fn forcepush_allowed() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
controller
|
||||
.amend(*project_id, branch_id, commit_id, &to_amend)
|
||||
.amend(project, branch_id, commit_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -76,24 +77,24 @@ async fn forcepush_allowed() {
|
||||
async fn forcepush_forbidden() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch_id,
|
||||
allow_rebasing: Some(false),
|
||||
@ -106,12 +107,12 @@ async fn forcepush_forbidden() {
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -120,7 +121,7 @@ async fn forcepush_forbidden() {
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
assert_eq!(
|
||||
controller
|
||||
.amend(*project_id, branch_id, commit_oid, &to_amend)
|
||||
.amend(project, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
@ -133,30 +134,30 @@ async fn forcepush_forbidden() {
|
||||
async fn non_locked_hunk() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -172,12 +173,12 @@ async fn non_locked_hunk() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
controller
|
||||
.amend(*project_id, branch_id, commit_oid, &to_amend)
|
||||
.amend(project, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -194,30 +195,30 @@ async fn non_locked_hunk() {
|
||||
async fn locked_hunk() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -237,12 +238,12 @@ async fn locked_hunk() {
|
||||
fs::write(repository.path().join("file.txt"), "more content").unwrap();
|
||||
let to_amend: branch::BranchOwnershipClaims = "file.txt:1-2".parse().unwrap();
|
||||
controller
|
||||
.amend(*project_id, branch_id, commit_oid, &to_amend)
|
||||
.amend(project, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -264,30 +265,30 @@ async fn locked_hunk() {
|
||||
async fn non_existing_ownership() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -303,7 +304,7 @@ async fn non_existing_ownership() {
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
assert_eq!(
|
||||
controller
|
||||
.amend(*project_id, branch_id, commit_oid, &to_amend)
|
||||
.amend(project, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
|
@ -4,7 +4,7 @@ use super::*;
|
||||
async fn rebase_commit() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -21,24 +21,24 @@ async fn rebase_commit() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut branch1_id = {
|
||||
// create a branch with some commited work
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("another_file.txt"), "virtual").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "virtual commit", None, false)
|
||||
.create_commit(project, branch1_id, "virtual commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
@ -51,7 +51,7 @@ async fn rebase_commit() {
|
||||
let unapplied_branch = {
|
||||
// unapply first vbranch
|
||||
let unapplied_branch = controller
|
||||
.convert_to_real_branch(*project_id, branch1_id, Default::default())
|
||||
.convert_to_real_branch(project, branch1_id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -64,7 +64,7 @@ async fn rebase_commit() {
|
||||
"one"
|
||||
);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(&unapplied_branch).unwrap()
|
||||
@ -72,10 +72,10 @@ async fn rebase_commit() {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// branch is stil unapplied
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
assert_eq!(
|
||||
@ -91,12 +91,12 @@ async fn rebase_commit() {
|
||||
{
|
||||
// apply first vbranch again
|
||||
branch1_id = controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// it should be rebased
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 0);
|
||||
@ -120,7 +120,7 @@ async fn rebase_commit() {
|
||||
async fn rebase_work() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -135,19 +135,19 @@ async fn rebase_work() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut branch1_id = {
|
||||
// make a branch with some work
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("another_file.txt"), "").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
@ -160,11 +160,11 @@ async fn rebase_work() {
|
||||
let unapplied_branch = {
|
||||
// unapply first vbranch
|
||||
let unapplied_branch = controller
|
||||
.convert_to_real_branch(*project_id, branch1_id, Default::default())
|
||||
.convert_to_real_branch(project, branch1_id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
assert!(!repository.path().join("another_file.txt").exists());
|
||||
@ -175,10 +175,10 @@ async fn rebase_work() {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// first branch is stil unapplied
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
assert!(!repository.path().join("another_file.txt").exists());
|
||||
@ -188,12 +188,12 @@ async fn rebase_work() {
|
||||
{
|
||||
// apply first vbranch again
|
||||
branch1_id = controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// workdir should be rebased, and work should be restored
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
|
@ -3,37 +3,37 @@ use super::*;
|
||||
#[tokio::test]
|
||||
async fn unapply_with_data() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
controller
|
||||
.convert_to_real_branch(*project_id, branches[0].id, Default::default())
|
||||
.convert_to_real_branch(project, branches[0].id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(!repository.path().join("file.txt").exists());
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn conflicting() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
@ -50,7 +50,7 @@ async fn conflicting() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -59,7 +59,7 @@ async fn conflicting() {
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].base_current);
|
||||
assert!(branches[0].active);
|
||||
@ -69,7 +69,7 @@ async fn conflicting() {
|
||||
);
|
||||
|
||||
let unapplied_branch = controller
|
||||
.convert_to_real_branch(*project_id, branches[0].id, Default::default())
|
||||
.convert_to_real_branch(project, branches[0].id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -78,7 +78,7 @@ async fn conflicting() {
|
||||
|
||||
{
|
||||
// update base branch, causing conflict
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(repository.path().join("file.txt")).unwrap(),
|
||||
@ -89,7 +89,7 @@ async fn conflicting() {
|
||||
let branch_id = {
|
||||
// apply branch, it should conflict
|
||||
let branch_id = controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -98,7 +98,7 @@ async fn conflicting() {
|
||||
"<<<<<<< ours\nconflict\n=======\nsecond\n>>>>>>> theirs\n"
|
||||
);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
|
||||
assert_eq!(branches.len(), 1);
|
||||
let branch = &branches[0];
|
||||
@ -115,7 +115,7 @@ async fn conflicting() {
|
||||
{
|
||||
// Converting the branch to a real branch should put us back in an unconflicted state
|
||||
controller
|
||||
.convert_to_real_branch(*project_id, branch_id, Default::default())
|
||||
.convert_to_real_branch(project, branch_id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -129,29 +129,29 @@ async fn conflicting() {
|
||||
#[tokio::test]
|
||||
async fn delete_if_empty() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
controller
|
||||
.convert_to_real_branch(*project_id, branches[0].id, Default::default())
|
||||
.convert_to_real_branch(project, branches[0].id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
}
|
||||
|
@ -8,19 +8,19 @@ use super::*;
|
||||
#[tokio::test]
|
||||
async fn should_lock_updated_hunks() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -28,7 +28,7 @@ async fn should_lock_updated_hunks() {
|
||||
// by default, hunks are not locked
|
||||
repository.write_file("file.txt", &["content".to_string()]);
|
||||
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, project, branch_id).await;
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert_eq!(branch.files[0].path.display().to_string(), "file.txt");
|
||||
assert_eq!(branch.files[0].hunks.len(), 1);
|
||||
@ -36,7 +36,7 @@ async fn should_lock_updated_hunks() {
|
||||
}
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "test", None, false)
|
||||
.create_commit(project, branch_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -45,7 +45,7 @@ async fn should_lock_updated_hunks() {
|
||||
repository.write_file("file.txt", &["updated content".to_string()]);
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -62,7 +62,7 @@ async fn should_lock_updated_hunks() {
|
||||
#[tokio::test]
|
||||
async fn should_not_lock_disjointed_hunks() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
@ -74,12 +74,12 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
repository.push();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -87,7 +87,7 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
// new hunk in the middle of the file
|
||||
lines[12] = "commited stuff".to_string();
|
||||
repository.write_file("file.txt", &lines);
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, project, branch_id).await;
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert_eq!(branch.files[0].path.display().to_string(), "file.txt");
|
||||
assert_eq!(branch.files[0].hunks.len(), 1);
|
||||
@ -95,11 +95,11 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
}
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "test commit", None, false)
|
||||
.create_commit(project, branch_id, "test commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -108,7 +108,7 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
let mut changed_lines = lines.clone();
|
||||
changed_lines[8] = "updated line".to_string();
|
||||
repository.write_file("file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, project, branch_id).await;
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert_eq!(branch.files[0].path.display().to_string(), "file.txt");
|
||||
assert_eq!(branch.files[0].hunks.len(), 1);
|
||||
@ -121,7 +121,7 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
let mut changed_lines = lines.clone();
|
||||
changed_lines[16] = "updated line".to_string();
|
||||
repository.write_file("file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, project, branch_id).await;
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert_eq!(branch.files[0].path.display().to_string(), "file.txt");
|
||||
assert_eq!(branch.files[0].hunks.len(), 1);
|
||||
@ -134,7 +134,7 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
let mut changed_lines = lines.clone();
|
||||
changed_lines[10] = "updated line".to_string();
|
||||
repository.write_file("file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, project, branch_id).await;
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert_eq!(branch.files[0].path.display().to_string(), "file.txt");
|
||||
assert_eq!(branch.files[0].hunks.len(), 1);
|
||||
@ -148,7 +148,7 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
let mut changed_lines = lines.clone();
|
||||
changed_lines[14] = "updated line".to_string();
|
||||
repository.write_file("file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, project, branch_id).await;
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert_eq!(branch.files[0].path.display().to_string(), "file.txt");
|
||||
assert_eq!(branch.files[0].hunks.len(), 1);
|
||||
@ -162,7 +162,7 @@ async fn should_not_lock_disjointed_hunks() {
|
||||
#[tokio::test]
|
||||
async fn should_reset_into_same_branch() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
@ -172,18 +172,18 @@ async fn should_reset_into_same_branch() {
|
||||
commit_and_push_initial(repository);
|
||||
|
||||
let base_branch = controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_2_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -196,11 +196,11 @@ async fn should_reset_into_same_branch() {
|
||||
repository.write_file("file.txt", &lines);
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_2_id, "commit to branch 2", None, false)
|
||||
.create_commit(project, branch_2_id, "commit to branch 2", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let files = get_virtual_branch(controller, *project_id, branch_2_id)
|
||||
let files = get_virtual_branch(controller, project, branch_2_id)
|
||||
.await
|
||||
.files;
|
||||
assert_eq!(files.len(), 0);
|
||||
@ -208,7 +208,7 @@ async fn should_reset_into_same_branch() {
|
||||
// Set target to branch 1 and verify the file resets into branch 2.
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch_2_id,
|
||||
selected_for_changes: Some(true),
|
||||
@ -219,11 +219,11 @@ async fn should_reset_into_same_branch() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reset_virtual_branch(*project_id, branch_2_id, base_branch.base_sha)
|
||||
.reset_virtual_branch(project, branch_2_id, base_branch.base_sha)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let files = get_virtual_branch(controller, *project_id, branch_2_id)
|
||||
let files = get_virtual_branch(controller, project, branch_2_id)
|
||||
.await
|
||||
.files;
|
||||
assert_eq!(files.len(), 1);
|
||||
@ -232,7 +232,7 @@ async fn should_reset_into_same_branch() {
|
||||
#[tokio::test]
|
||||
async fn should_double_lock() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
@ -243,12 +243,12 @@ async fn should_double_lock() {
|
||||
commit_and_push_initial(repository);
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -256,7 +256,7 @@ async fn should_double_lock() {
|
||||
repository.write_file("file.txt", &lines);
|
||||
|
||||
let commit_1 = controller
|
||||
.create_commit(*project_id, branch_id, "commit 1", None, false)
|
||||
.create_commit(project, branch_id, "commit 1", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -264,14 +264,14 @@ async fn should_double_lock() {
|
||||
repository.write_file("file.txt", &lines);
|
||||
|
||||
let commit_2 = controller
|
||||
.create_commit(*project_id, branch_id, "commit 2", None, false)
|
||||
.create_commit(project, branch_id, "commit 2", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
lines[3] = "change3".to_string();
|
||||
repository.write_file("file.txt", &lines);
|
||||
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, project, branch_id).await;
|
||||
let locks = &branch.files[0].hunks[0].locked_to.clone().unwrap();
|
||||
|
||||
assert_eq!(locks.len(), 2);
|
||||
@ -286,11 +286,11 @@ fn commit_and_push_initial(repository: &TestProject) {
|
||||
|
||||
async fn get_virtual_branch(
|
||||
controller: &Controller,
|
||||
project_id: ProjectId,
|
||||
project: &Project,
|
||||
branch_id: Id<Branch>,
|
||||
) -> VirtualBranch {
|
||||
controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -4,13 +4,13 @@ use super::*;
|
||||
async fn integration() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -18,22 +18,22 @@ async fn integration() {
|
||||
// make a remote branch
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &super::branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &super::branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "first\n").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "first", None, false)
|
||||
.create_commit(project, branch_id, "first", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -44,7 +44,7 @@ async fn integration() {
|
||||
let name = branch.upstream.unwrap().name;
|
||||
|
||||
controller
|
||||
.delete_virtual_branch(*project_id, branch_id)
|
||||
.delete_virtual_branch(project, branch_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -53,7 +53,7 @@ async fn integration() {
|
||||
|
||||
// checkout a existing remote branch
|
||||
let branch_id = controller
|
||||
.create_virtual_branch_from_branch(*project_id, &branch_name)
|
||||
.create_virtual_branch_from_branch(project, &branch_name)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -62,7 +62,7 @@ async fn integration() {
|
||||
std::fs::write(repository.path().join("file.txt"), "first\nsecond").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "second", None, false)
|
||||
.create_commit(project, branch_id, "second", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
@ -79,12 +79,12 @@ async fn integration() {
|
||||
{
|
||||
// merge branch into master
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -102,13 +102,10 @@ async fn integration() {
|
||||
|
||||
{
|
||||
// should mark commits as integrated
|
||||
controller
|
||||
.fetch_from_remotes(*project_id, None)
|
||||
.await
|
||||
.unwrap();
|
||||
controller.fetch_from_remotes(project, None).await.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -127,7 +124,7 @@ async fn integration() {
|
||||
async fn no_conflicts() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -143,22 +140,19 @@ async fn no_conflicts() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert!(branches.is_empty());
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
*project_id,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.create_virtual_branch_from_branch(project, &"refs/remotes/origin/branch".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -169,7 +163,7 @@ async fn no_conflicts() {
|
||||
async fn conflicts_with_uncommited() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -185,7 +179,7 @@ async fn conflicts_with_uncommited() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -193,21 +187,18 @@ async fn conflicts_with_uncommited() {
|
||||
{
|
||||
std::fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
};
|
||||
|
||||
// branch should be created unapplied, because of the conflict
|
||||
|
||||
let new_branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
*project_id,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.create_virtual_branch_from_branch(project, &"refs/remotes/origin/branch".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
let new_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -223,7 +214,7 @@ async fn conflicts_with_uncommited() {
|
||||
async fn conflicts_with_commited() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -239,7 +230,7 @@ async fn conflicts_with_commited() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -247,11 +238,11 @@ async fn conflicts_with_commited() {
|
||||
{
|
||||
std::fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branches[0].id, "hej", None, false)
|
||||
.create_commit(project, branches[0].id, "hej", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
};
|
||||
@ -259,14 +250,11 @@ async fn conflicts_with_commited() {
|
||||
// branch should be created unapplied, because of the conflict
|
||||
|
||||
let new_branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
*project_id,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.create_virtual_branch_from_branch(project, &"refs/remotes/origin/branch".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
let new_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -281,13 +269,13 @@ async fn conflicts_with_commited() {
|
||||
#[tokio::test]
|
||||
async fn from_default_target() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -296,7 +284,7 @@ async fn from_default_target() {
|
||||
assert_eq!(
|
||||
controller
|
||||
.create_virtual_branch_from_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&"refs/remotes/origin/master".parse().unwrap(),
|
||||
)
|
||||
.await
|
||||
@ -309,13 +297,13 @@ async fn from_default_target() {
|
||||
#[tokio::test]
|
||||
async fn from_non_existent_branch() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -324,7 +312,7 @@ async fn from_non_existent_branch() {
|
||||
assert_eq!(
|
||||
controller
|
||||
.create_virtual_branch_from_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.await
|
||||
@ -338,7 +326,7 @@ async fn from_non_existent_branch() {
|
||||
async fn from_state_remote_branch() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -359,19 +347,16 @@ async fn from_state_remote_branch() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
*project_id,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.create_virtual_branch_from_branch(project, &"refs/remotes/origin/branch".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
|
@ -3,28 +3,28 @@ use super::*;
|
||||
#[tokio::test]
|
||||
async fn should_unapply_diff() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// write some
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
|
||||
controller
|
||||
.delete_virtual_branch(*project_id, branches[0].id)
|
||||
.delete_virtual_branch(project, branches[0].id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert!(!repository.path().join("file.txt").exists());
|
||||
|
||||
@ -39,20 +39,20 @@ async fn should_unapply_diff() {
|
||||
#[tokio::test]
|
||||
async fn should_remove_reference() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -61,12 +61,9 @@ async fn should_remove_reference() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.delete_virtual_branch(*project_id, id)
|
||||
.await
|
||||
.unwrap();
|
||||
controller.delete_virtual_branch(project, id).await.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
let refnames = repository
|
||||
|
@ -3,37 +3,34 @@ use super::*;
|
||||
#[tokio::test]
|
||||
async fn should_update_last_fetched() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
projects,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let before_fetch = controller.get_base_branch_data(*project_id).await.unwrap();
|
||||
let before_fetch = controller.get_base_branch_data(project).await.unwrap();
|
||||
assert!(before_fetch.last_fetched_ms.is_none());
|
||||
|
||||
let fetch = controller
|
||||
.fetch_from_remotes(*project_id, None)
|
||||
.await
|
||||
.unwrap();
|
||||
let fetch = controller.fetch_from_remotes(project, None).await.unwrap();
|
||||
assert!(fetch.last_fetched_ms.is_some());
|
||||
|
||||
let after_fetch = controller.get_base_branch_data(*project_id).await.unwrap();
|
||||
let project = &projects.get(project.id).unwrap();
|
||||
let after_fetch = controller.get_base_branch_data(project).await.unwrap();
|
||||
assert!(after_fetch.last_fetched_ms.is_some());
|
||||
assert_eq!(fetch.last_fetched_ms, after_fetch.last_fetched_ms);
|
||||
|
||||
let second_fetch = controller
|
||||
.fetch_from_remotes(*project_id, None)
|
||||
.await
|
||||
.unwrap();
|
||||
let second_fetch = controller.fetch_from_remotes(project, None).await.unwrap();
|
||||
assert!(second_fetch.last_fetched_ms.is_some());
|
||||
assert_ne!(fetch.last_fetched_ms, second_fetch.last_fetched_ms);
|
||||
|
||||
let after_second_fetch = controller.get_base_branch_data(*project_id).await.unwrap();
|
||||
let project = &projects.get(project.id).unwrap();
|
||||
let after_second_fetch = controller.get_base_branch_data(project).await.unwrap();
|
||||
assert!(after_second_fetch.last_fetched_ms.is_some());
|
||||
assert_eq!(
|
||||
second_fetch.last_fetched_ms,
|
||||
|
@ -15,18 +15,18 @@ async fn twice() {
|
||||
.add(test_project.path())
|
||||
.expect("failed to add project");
|
||||
controller
|
||||
.set_base_branch(project.id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(&project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(controller
|
||||
.list_virtual_branches(project.id)
|
||||
.list_virtual_branches(&project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
.is_empty());
|
||||
projects.delete(project.id).await.unwrap();
|
||||
controller
|
||||
.list_virtual_branches(project.id)
|
||||
.list_virtual_branches(&project)
|
||||
.await
|
||||
.unwrap_err();
|
||||
}
|
||||
@ -34,13 +34,13 @@ async fn twice() {
|
||||
{
|
||||
let project = projects.add(test_project.path()).unwrap();
|
||||
controller
|
||||
.set_base_branch(project.id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(&project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// even though project is on gitbutler/integration, we should not import it
|
||||
assert!(controller
|
||||
.list_virtual_branches(project.id)
|
||||
.list_virtual_branches(&project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -54,7 +54,7 @@ async fn dirty_non_target() {
|
||||
// that has uncommited changes.
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -64,11 +64,11 @@ async fn dirty_non_target() {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks.len(), 1);
|
||||
@ -82,7 +82,7 @@ async fn dirty_target() {
|
||||
// that has uncommited changes.
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -90,11 +90,11 @@ async fn dirty_target() {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks.len(), 1);
|
||||
@ -106,7 +106,7 @@ async fn dirty_target() {
|
||||
async fn commit_on_non_target_local() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -116,11 +116,11 @@ async fn commit_on_non_target_local() {
|
||||
repository.commit_all("commit on target");
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].files.is_empty());
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -132,7 +132,7 @@ async fn commit_on_non_target_local() {
|
||||
async fn commit_on_non_target_remote() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -143,11 +143,11 @@ async fn commit_on_non_target_remote() {
|
||||
repository.push_branch(&"refs/heads/some-feature".parse().unwrap());
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].files.is_empty());
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -159,7 +159,7 @@ async fn commit_on_non_target_remote() {
|
||||
async fn commit_on_target() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -168,11 +168,11 @@ async fn commit_on_target() {
|
||||
repository.commit_all("commit on target");
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].files.is_empty());
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -184,21 +184,21 @@ async fn commit_on_target() {
|
||||
async fn submodule() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
let project = TestProject::default();
|
||||
let submodule_url: git::Url = project.path().display().to_string().parse().unwrap();
|
||||
let test_project = TestProject::default();
|
||||
let submodule_url: git::Url = test_project.path().display().to_string().parse().unwrap();
|
||||
repository.add_submodule(&submodule_url, path::Path::new("submodule"));
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks.len(), 1);
|
||||
|
@ -4,25 +4,25 @@ use super::*;
|
||||
async fn insert_blank_commit_down() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let _commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -30,24 +30,24 @@ async fn insert_blank_commit_down() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file4.txt"), "content4").unwrap();
|
||||
let _commit3_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.insert_blank_commit(*project_id, branch_id, commit2_id, 1)
|
||||
.insert_blank_commit(project, branch_id, commit2_id, 1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -76,25 +76,25 @@ async fn insert_blank_commit_down() {
|
||||
async fn insert_blank_commit_up() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let _commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -102,24 +102,24 @@ async fn insert_blank_commit_up() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file4.txt"), "content4").unwrap();
|
||||
let _commit3_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.insert_blank_commit(*project_id, branch_id, commit2_id, -1)
|
||||
.insert_blank_commit(project, branch_id, commit2_id, -1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -89,7 +89,7 @@ mod verify_branch;
|
||||
async fn resolve_conflict_flow() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -107,19 +107,19 @@ async fn resolve_conflict_flow() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
// make a branch that conflicts with the remote branch, but doesn't know about it yet
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
@ -127,11 +127,11 @@ async fn resolve_conflict_flow() {
|
||||
|
||||
let unapplied_branch = {
|
||||
// fetch remote. There is now a conflict, so the branch will be unapplied
|
||||
let unapplied_branches = controller.update_base_branch(*project_id).await.unwrap();
|
||||
let unapplied_branches = controller.update_base_branch(project).await.unwrap();
|
||||
assert_eq!(unapplied_branches.len(), 1);
|
||||
|
||||
// there is a conflict now, so the branch should be inactive
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(&unapplied_branches[0]).unwrap()
|
||||
@ -140,11 +140,11 @@ async fn resolve_conflict_flow() {
|
||||
let branch1_id = {
|
||||
// when we apply conflicted branch, it has conflict
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].active);
|
||||
assert!(branches[0].conflicted);
|
||||
@ -163,7 +163,7 @@ async fn resolve_conflict_flow() {
|
||||
// can't commit conflicts
|
||||
assert!(matches!(
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "commit conflicts", None, false)
|
||||
.create_commit(project, branch1_id, "commit conflicts", None, false)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -174,16 +174,16 @@ async fn resolve_conflict_flow() {
|
||||
{
|
||||
// fixing the conflict removes conflicted mark
|
||||
fs::write(repository.path().join("file.txt"), "resolved").unwrap();
|
||||
controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
controller.list_virtual_branches(project).await.unwrap();
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, branch1_id, "resolution", None, false)
|
||||
.create_commit(project, branch1_id, "resolution", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit = repository.find_commit(commit_oid).unwrap();
|
||||
assert_eq!(commit.parent_count(), 2);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
|
@ -6,25 +6,25 @@ use super::*;
|
||||
async fn move_file_down() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
let commit1 = repository.find_commit(commit1_id).unwrap();
|
||||
@ -33,7 +33,7 @@ async fn move_file_down() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
let commit2 = repository.find_commit(commit2_id).unwrap();
|
||||
@ -41,12 +41,12 @@ async fn move_file_down() {
|
||||
// amend another hunk
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
controller
|
||||
.move_commit_file(*project_id, branch_id, commit2_id, commit1_id, &to_amend)
|
||||
.move_commit_file(project, branch_id, commit2_id, commit1_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -70,18 +70,18 @@ async fn move_file_down() {
|
||||
async fn move_file_up() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -89,26 +89,26 @@ async fn move_file_up() {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
let commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// amend another hunk
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
controller
|
||||
.move_commit_file(*project_id, branch_id, commit1_id, commit2_id, &to_amend)
|
||||
.move_commit_file(project, branch_id, commit1_id, commit2_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -135,19 +135,19 @@ async fn move_file_up_overlapping_hunks() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create bottom commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let _commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -155,7 +155,7 @@ async fn move_file_up_overlapping_hunks() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2\ncontent2a\n").unwrap();
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -167,26 +167,26 @@ async fn move_file_up_overlapping_hunks() {
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("file4.txt"), "content4").unwrap();
|
||||
let commit3_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create top commit
|
||||
fs::write(repository.path().join("file5.txt"), "content5").unwrap();
|
||||
let _commit4_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit four", None, false)
|
||||
.create_commit(project, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// move one line from middle commit two up to middle commit one
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-6".parse().unwrap();
|
||||
controller
|
||||
.move_commit_file(*project_id, branch_id, commit2_id, commit3_id, &to_amend)
|
||||
.move_commit_file(project, branch_id, commit2_id, commit3_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -6,40 +6,40 @@ use crate::suite::virtual_branches::Test;
|
||||
async fn no_diffs() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
let source_branch_id = branches[0].id;
|
||||
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, source_branch_id, "commit", None, false)
|
||||
.create_commit(project, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let target_branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.move_commit(project, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let destination_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -48,7 +48,7 @@ async fn no_diffs() {
|
||||
.unwrap();
|
||||
|
||||
let source_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -66,25 +66,25 @@ async fn no_diffs() {
|
||||
async fn diffs_on_source_branch() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
let source_branch_id = branches[0].id;
|
||||
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, source_branch_id, "commit", None, false)
|
||||
.create_commit(project, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -95,17 +95,17 @@ async fn diffs_on_source_branch() {
|
||||
.unwrap();
|
||||
|
||||
let target_branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.move_commit(project, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let destination_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -114,7 +114,7 @@ async fn diffs_on_source_branch() {
|
||||
.unwrap();
|
||||
|
||||
let source_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -132,31 +132,31 @@ async fn diffs_on_source_branch() {
|
||||
async fn diffs_on_target_branch() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
let source_branch_id = branches[0].id;
|
||||
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, source_branch_id, "commit", None, false)
|
||||
.create_commit(project, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let target_branch_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -172,12 +172,12 @@ async fn diffs_on_target_branch() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.move_commit(project, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let destination_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -186,7 +186,7 @@ async fn diffs_on_target_branch() {
|
||||
.unwrap();
|
||||
|
||||
let source_branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -204,38 +204,38 @@ async fn diffs_on_target_branch() {
|
||||
async fn locked_hunks_on_source_branch() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
let source_branch_id = branches[0].id;
|
||||
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, source_branch_id, "commit", None, false)
|
||||
.create_commit(project, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "locked content").unwrap();
|
||||
|
||||
let target_branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
controller
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.move_commit(project, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
@ -247,30 +247,30 @@ async fn locked_hunks_on_source_branch() {
|
||||
async fn no_commit() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
let source_branch_id = branches[0].id;
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, source_branch_id, "commit", None, false)
|
||||
.create_commit(project, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let target_branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -278,7 +278,7 @@ async fn no_commit() {
|
||||
assert_eq!(
|
||||
controller
|
||||
.move_commit(
|
||||
*project_id,
|
||||
project,
|
||||
target_branch_id,
|
||||
git2::Oid::from_str(commit_id_hex).unwrap()
|
||||
)
|
||||
@ -293,32 +293,32 @@ async fn no_commit() {
|
||||
async fn no_branch() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
let source_branch_id = branches[0].id;
|
||||
|
||||
let commit_oid = controller
|
||||
.create_commit(*project_id, source_branch_id, "commit", None, false)
|
||||
.create_commit(project, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let id = BranchId::generate();
|
||||
assert_eq!(
|
||||
controller
|
||||
.move_commit(*project_id, id, commit_oid)
|
||||
.move_commit(project, id, commit_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
|
@ -9,14 +9,13 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
|
||||
let test = Test::default();
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
controller,
|
||||
project,
|
||||
..
|
||||
} = &test;
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -29,7 +28,7 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
|
||||
)?;
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some(round.to_string()),
|
||||
..Default::default()
|
||||
@ -38,7 +37,7 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
|
||||
.await?;
|
||||
controller
|
||||
.create_commit(
|
||||
*project_id,
|
||||
project,
|
||||
branch_id,
|
||||
&format!("commit {round}"),
|
||||
None,
|
||||
@ -56,7 +55,7 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
|
||||
);
|
||||
}
|
||||
let _empty = controller
|
||||
.create_virtual_branch(*project_id, &Default::default())
|
||||
.create_virtual_branch(project, &Default::default())
|
||||
.await?;
|
||||
|
||||
let snapshots = project.list_snapshots(10, None)?;
|
||||
@ -102,24 +101,23 @@ fn make_lines(count: usize) -> Vec<u8> {
|
||||
async fn basic_oplog() -> anyhow::Result<()> {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
controller,
|
||||
project,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse()?)
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse()?)
|
||||
.await?;
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await?;
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content")?;
|
||||
let _commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await?;
|
||||
|
||||
// dont store large files
|
||||
@ -135,7 +133,7 @@ async fn basic_oplog() -> anyhow::Result<()> {
|
||||
fs::write(repository.path().join("file2.txt"), "content2")?;
|
||||
fs::write(repository.path().join("file3.txt"), "content3")?;
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await?;
|
||||
|
||||
// Create conflict state
|
||||
@ -146,7 +144,7 @@ async fn basic_oplog() -> anyhow::Result<()> {
|
||||
|
||||
// create state with conflict state
|
||||
let _empty_branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await?;
|
||||
|
||||
std::fs::remove_file(&base_merge_parent_path)?;
|
||||
@ -154,18 +152,18 @@ async fn basic_oplog() -> anyhow::Result<()> {
|
||||
|
||||
fs::write(repository.path().join("file4.txt"), "content4")?;
|
||||
let _commit3_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await?;
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await?
|
||||
.0
|
||||
.into_iter()
|
||||
.find(|b| b.id == branch_id)
|
||||
.unwrap();
|
||||
|
||||
let branches = controller.list_virtual_branches(*project_id).await?;
|
||||
let branches = controller.list_virtual_branches(project).await?;
|
||||
assert_eq!(branches.0.len(), 2);
|
||||
|
||||
assert_eq!(branch.commits.len(), 3);
|
||||
@ -204,7 +202,7 @@ async fn basic_oplog() -> anyhow::Result<()> {
|
||||
project.restore_snapshot(snapshots[2].clone().commit_id)?;
|
||||
|
||||
// the restore removed our new branch
|
||||
let branches = controller.list_virtual_branches(*project_id).await?;
|
||||
let branches = controller.list_virtual_branches(project).await?;
|
||||
assert_eq!(branches.0.len(), 1);
|
||||
|
||||
// assert that the conflicts file was removed
|
||||
@ -252,26 +250,25 @@ async fn basic_oplog() -> anyhow::Result<()> {
|
||||
async fn restores_gitbutler_integration() -> anyhow::Result<()> {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
controller,
|
||||
project,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse()?)
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse()?)
|
||||
.await?;
|
||||
|
||||
assert_eq!(project.virtual_branches().list_branches()?.len(), 0);
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await?;
|
||||
assert_eq!(project.virtual_branches().list_branches()?.len(), 1);
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content")?;
|
||||
let _commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await?;
|
||||
|
||||
let repo = git2::Repository::open(&project.path)?;
|
||||
@ -286,7 +283,7 @@ async fn restores_gitbutler_integration() -> anyhow::Result<()> {
|
||||
// create second commit
|
||||
fs::write(repository.path().join("file.txt"), "changed content")?;
|
||||
let _commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await?;
|
||||
|
||||
// check the integration commit changed
|
||||
@ -365,18 +362,17 @@ async fn restores_gitbutler_integration() -> anyhow::Result<()> {
|
||||
async fn head_corrupt_is_recreated_automatically() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
controller,
|
||||
project,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -396,7 +392,7 @@ async fn head_corrupt_is_recreated_automatically() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.expect("the snapshot doesn't fail despite the corrupt head");
|
||||
|
||||
|
@ -6,23 +6,23 @@ mod create_virtual_branch {
|
||||
#[tokio::test]
|
||||
async fn simple() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].name, "Virtual branch");
|
||||
@ -38,20 +38,20 @@ mod create_virtual_branch {
|
||||
#[tokio::test]
|
||||
async fn duplicate_name() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&gitbutler_core::virtual_branches::branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -62,7 +62,7 @@ mod create_virtual_branch {
|
||||
|
||||
let branch2_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&gitbutler_core::virtual_branches::branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -71,7 +71,7 @@ mod create_virtual_branch {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 2);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].name, "name");
|
||||
@ -94,20 +94,20 @@ mod update_virtual_branch {
|
||||
#[tokio::test]
|
||||
async fn simple() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -118,7 +118,7 @@ mod update_virtual_branch {
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch_id,
|
||||
name: Some("new name".to_string()),
|
||||
@ -128,7 +128,7 @@ mod update_virtual_branch {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].name, "new name");
|
||||
@ -145,20 +145,20 @@ mod update_virtual_branch {
|
||||
#[tokio::test]
|
||||
async fn duplicate_name() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -169,7 +169,7 @@ mod update_virtual_branch {
|
||||
|
||||
let branch2_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
..Default::default()
|
||||
},
|
||||
@ -179,7 +179,7 @@ mod update_virtual_branch {
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch2_id,
|
||||
name: Some("name".to_string()),
|
||||
@ -189,7 +189,7 @@ mod update_virtual_branch {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 2);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].name, "name");
|
||||
@ -213,20 +213,20 @@ mod push_virtual_branch {
|
||||
#[tokio::test]
|
||||
async fn simple() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -238,15 +238,15 @@ mod push_virtual_branch {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "test", None, false)
|
||||
.create_commit(project, branch1_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch1_id, false, None)
|
||||
.push_virtual_branch(project, branch1_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].name, "name");
|
||||
@ -266,14 +266,14 @@ mod push_virtual_branch {
|
||||
#[tokio::test]
|
||||
async fn duplicate_names() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -281,7 +281,7 @@ mod push_virtual_branch {
|
||||
// create and push branch with some work
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -291,11 +291,11 @@ mod push_virtual_branch {
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "test", None, false)
|
||||
.create_commit(project, branch1_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch1_id, false, None)
|
||||
.push_virtual_branch(project, branch1_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
branch1_id
|
||||
@ -304,7 +304,7 @@ mod push_virtual_branch {
|
||||
// rename first branch
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch1_id,
|
||||
name: Some("updated name".to_string()),
|
||||
@ -318,7 +318,7 @@ mod push_virtual_branch {
|
||||
// create another branch with first branch's old name and push it
|
||||
let branch2_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -328,17 +328,17 @@ mod push_virtual_branch {
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("file.txt"), "updated content").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch2_id, "test", None, false)
|
||||
.create_commit(project, branch2_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch2_id, false, None)
|
||||
.push_virtual_branch(project, branch2_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
branch2_id
|
||||
};
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 2);
|
||||
// first branch is pushing to old ref remotely
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
|
@ -4,25 +4,25 @@ use super::*;
|
||||
async fn reorder_commit_down() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let _commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -30,17 +30,17 @@ async fn reorder_commit_down() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reorder_commit(*project_id, branch_id, commit2_id, 1)
|
||||
.reorder_commit(project, branch_id, commit2_id, 1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -65,25 +65,25 @@ async fn reorder_commit_down() {
|
||||
async fn reorder_commit_up() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -91,17 +91,17 @@ async fn reorder_commit_up() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let _commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reorder_commit(*project_id, branch_id, commit1_id, -1)
|
||||
.reorder_commit(project, branch_id, commit1_id, -1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -8,18 +8,18 @@ use crate::suite::virtual_branches::Test;
|
||||
async fn to_head() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -28,11 +28,11 @@ async fn to_head() {
|
||||
|
||||
// commit changes
|
||||
let oid = controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -49,11 +49,11 @@ async fn to_head() {
|
||||
{
|
||||
// reset changes to head
|
||||
controller
|
||||
.reset_virtual_branch(*project_id, branch1_id, oid)
|
||||
.reset_virtual_branch(project, branch1_id, oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -70,18 +70,18 @@ async fn to_head() {
|
||||
async fn to_target() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
let base_branch = controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -90,11 +90,11 @@ async fn to_target() {
|
||||
|
||||
// commit changes
|
||||
let oid = controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -109,11 +109,11 @@ async fn to_target() {
|
||||
{
|
||||
// reset changes to head
|
||||
controller
|
||||
.reset_virtual_branch(*project_id, branch1_id, base_branch.base_sha)
|
||||
.reset_virtual_branch(project, branch1_id, base_branch.base_sha)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 0);
|
||||
@ -129,18 +129,18 @@ async fn to_target() {
|
||||
async fn to_commit() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -150,11 +150,11 @@ async fn to_commit() {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let oid = controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -173,11 +173,11 @@ async fn to_commit() {
|
||||
fs::write(repository.path().join("file.txt"), "more content").unwrap();
|
||||
|
||||
let second_commit_oid = controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 2);
|
||||
@ -193,11 +193,11 @@ async fn to_commit() {
|
||||
{
|
||||
// reset changes to the first commit
|
||||
controller
|
||||
.reset_virtual_branch(*project_id, branch1_id, first_commit_oid)
|
||||
.reset_virtual_branch(project, branch1_id, first_commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -214,18 +214,18 @@ async fn to_commit() {
|
||||
async fn to_non_existing() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -234,11 +234,11 @@ async fn to_non_existing() {
|
||||
|
||||
// commit changes
|
||||
let oid = controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -255,7 +255,7 @@ async fn to_non_existing() {
|
||||
assert_eq!(
|
||||
controller
|
||||
.reset_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch1_id,
|
||||
"fe14df8c66b73c6276f7bb26102ad91da680afcb".parse().unwrap()
|
||||
)
|
||||
|
@ -4,13 +4,13 @@ use super::*;
|
||||
async fn unapplying_selected_branch_selects_anther() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -18,17 +18,17 @@ async fn unapplying_selected_branch_selects_anther() {
|
||||
|
||||
// first branch should be created as default
|
||||
let b_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// if default branch exists, new branch should not be created as default
|
||||
let b2_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
|
||||
let b = branches.iter().find(|b| b.id == b_id).unwrap();
|
||||
|
||||
@ -38,11 +38,11 @@ async fn unapplying_selected_branch_selects_anther() {
|
||||
assert!(!b2.selected_for_changes);
|
||||
|
||||
controller
|
||||
.convert_to_real_branch(*project_id, b_id, Default::default())
|
||||
.convert_to_real_branch(project, b_id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, b2.id);
|
||||
@ -53,29 +53,29 @@ async fn unapplying_selected_branch_selects_anther() {
|
||||
#[tokio::test]
|
||||
async fn deleting_selected_branch_selects_anther() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// first branch should be created as default
|
||||
let b_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// if default branch exists, new branch should not be created as default
|
||||
let b2_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
|
||||
let b = branches.iter().find(|b| b.id == b_id).unwrap();
|
||||
|
||||
@ -85,11 +85,11 @@ async fn deleting_selected_branch_selects_anther() {
|
||||
assert!(!b2.selected_for_changes);
|
||||
|
||||
controller
|
||||
.delete_virtual_branch(*project_id, b_id)
|
||||
.delete_virtual_branch(project, b_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, b2.id);
|
||||
@ -99,23 +99,23 @@ async fn deleting_selected_branch_selects_anther() {
|
||||
#[tokio::test]
|
||||
async fn create_virtual_branch_should_set_selected_for_changes() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// first branch should be created as default
|
||||
let b_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -126,11 +126,11 @@ 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_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -142,7 +142,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
|
||||
// explicitly don't make this one default
|
||||
let b_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(false),
|
||||
..Default::default()
|
||||
@ -151,7 +151,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
|
||||
.await
|
||||
.unwrap();
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -163,7 +163,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
|
||||
// explicitly make this one default
|
||||
let b_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -172,7 +172,7 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
|
||||
.await
|
||||
.unwrap();
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -185,22 +185,22 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
|
||||
#[tokio::test]
|
||||
async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let b1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let b1 = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -210,11 +210,11 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
assert!(b1.selected_for_changes);
|
||||
|
||||
let b2_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let b2 = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -225,7 +225,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: b2_id,
|
||||
selected_for_changes: Some(true),
|
||||
@ -236,7 +236,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
.unwrap();
|
||||
|
||||
let b1 = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -246,7 +246,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
assert!(!b1.selected_for_changes);
|
||||
|
||||
let b2 = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -260,24 +260,24 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
async fn unapply_virtual_branch_should_reset_selected_for_changes() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let b1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let b1 = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -287,12 +287,12 @@ async fn unapply_virtual_branch_should_reset_selected_for_changes() {
|
||||
assert!(b1.selected_for_changes);
|
||||
|
||||
let b2_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let b2 = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -302,12 +302,12 @@ async fn unapply_virtual_branch_should_reset_selected_for_changes() {
|
||||
assert!(!b2.selected_for_changes);
|
||||
|
||||
controller
|
||||
.convert_to_real_branch(*project_id, b1_id, Default::default())
|
||||
.convert_to_real_branch(project, b1_id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -319,24 +319,24 @@ async fn unapply_virtual_branch_should_reset_selected_for_changes() {
|
||||
async fn hunks_distribution() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
|
||||
controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -345,7 +345,7 @@ async fn hunks_distribution() {
|
||||
.await
|
||||
.unwrap();
|
||||
std::fs::write(repository.path().join("another_file.txt"), "content").unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[1].files.len(), 1);
|
||||
}
|
||||
@ -354,32 +354,32 @@ async fn hunks_distribution() {
|
||||
async fn applying_first_branch() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
let unapplied_branch = controller
|
||||
.convert_to_real_branch(*project_id, branches[0].id, Default::default())
|
||||
.convert_to_real_branch(project, branches[0].id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let unapplied_branch = git::Refname::from_str(&unapplied_branch).unwrap();
|
||||
controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].active);
|
||||
assert!(branches[0].selected_for_changes);
|
||||
@ -391,7 +391,7 @@ async fn applying_first_branch() {
|
||||
async fn new_locked_hunk_without_modifying_existing() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -401,28 +401,28 @@ async fn new_locked_hunk_without_modifying_existing() {
|
||||
repository.push();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
lines[0] = "modification 1".to_string();
|
||||
repository.write_file("file.txt", &lines);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branches[0].id, "second commit", None, false)
|
||||
.create_commit(project, branches[0].id, "second commit", None, false)
|
||||
.await
|
||||
.expect("failed to create commit");
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 0);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
|
||||
controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -434,13 +434,13 @@ async fn new_locked_hunk_without_modifying_existing() {
|
||||
lines[8] = "modification 2".to_string();
|
||||
repository.write_file("file.txt", &lines);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 0);
|
||||
assert_eq!(branches[1].files.len(), 1);
|
||||
|
||||
lines[0] = "modification 3".to_string();
|
||||
repository.write_file("file.txt", &lines);
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[1].files.len(), 1);
|
||||
}
|
||||
|
@ -3,13 +3,13 @@ use super::*;
|
||||
#[tokio::test]
|
||||
async fn success() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
@ -20,7 +20,7 @@ mod error {
|
||||
#[tokio::test]
|
||||
async fn missing() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -28,7 +28,7 @@ mod error {
|
||||
assert_eq!(
|
||||
controller
|
||||
.set_base_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&git::RemoteRefname::from_str("refs/remotes/origin/missing").unwrap(),
|
||||
)
|
||||
.await
|
||||
@ -48,7 +48,7 @@ mod go_back_to_integration {
|
||||
async fn should_preserve_applied_vbranches() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -60,32 +60,32 @@ mod go_back_to_integration {
|
||||
repository.push();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let vbranch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(repository.path().join("another file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, vbranch_id, "one", None, false)
|
||||
.create_commit(project, vbranch_id, "one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
repository.checkout_commit(oid_one);
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, vbranch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -95,7 +95,7 @@ mod go_back_to_integration {
|
||||
async fn from_target_branch_index_conflicts() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -107,11 +107,11 @@ mod go_back_to_integration {
|
||||
repository.push();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert!(branches.is_empty());
|
||||
|
||||
repository.checkout_commit(oid_one);
|
||||
@ -119,7 +119,7 @@ mod go_back_to_integration {
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -131,7 +131,7 @@ mod go_back_to_integration {
|
||||
async fn from_target_branch_with_uncommited() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -143,11 +143,11 @@ mod go_back_to_integration {
|
||||
repository.push();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert!(branches.is_empty());
|
||||
|
||||
repository.checkout_commit(oid_one);
|
||||
@ -155,7 +155,7 @@ mod go_back_to_integration {
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -167,7 +167,7 @@ mod go_back_to_integration {
|
||||
async fn from_target_branch_with_commit() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -179,11 +179,11 @@ mod go_back_to_integration {
|
||||
repository.push();
|
||||
|
||||
let base = controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert!(branches.is_empty());
|
||||
|
||||
repository.checkout_commit(oid_one);
|
||||
@ -191,11 +191,11 @@ mod go_back_to_integration {
|
||||
repository.commit_all("three");
|
||||
|
||||
let base_two = controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert_eq!(base_two, base);
|
||||
}
|
||||
@ -204,7 +204,7 @@ mod go_back_to_integration {
|
||||
async fn from_target_branch_without_any_changes() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -216,21 +216,21 @@ mod go_back_to_integration {
|
||||
repository.push();
|
||||
|
||||
let base = controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert!(branches.is_empty());
|
||||
|
||||
repository.checkout_commit(oid_one);
|
||||
|
||||
let base_two = controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert_eq!(base_two, base);
|
||||
}
|
||||
|
@ -4,25 +4,25 @@ use super::*;
|
||||
async fn head() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -30,7 +30,7 @@ async fn head() {
|
||||
{
|
||||
fs::write(repository.path().join("file two.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -38,7 +38,7 @@ async fn head() {
|
||||
{
|
||||
fs::write(repository.path().join("file three.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -46,18 +46,18 @@ async fn head() {
|
||||
let commit_four_oid = {
|
||||
fs::write(repository.path().join("file four.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit four", None, false)
|
||||
.create_commit(project, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.squash(*project_id, branch_id, commit_four_oid)
|
||||
.squash(project, branch_id, commit_four_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -80,25 +80,25 @@ async fn head() {
|
||||
async fn middle() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -106,7 +106,7 @@ async fn middle() {
|
||||
let commit_two_oid = {
|
||||
fs::write(repository.path().join("file two.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -114,7 +114,7 @@ async fn middle() {
|
||||
{
|
||||
fs::write(repository.path().join("file three.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -122,18 +122,18 @@ async fn middle() {
|
||||
{
|
||||
fs::write(repository.path().join("file four.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit four", None, false)
|
||||
.create_commit(project, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.squash(*project_id, branch_id, commit_two_oid)
|
||||
.squash(project, branch_id, commit_two_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -157,6 +157,7 @@ async fn forcepush_allowed() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
projects,
|
||||
..
|
||||
@ -171,32 +172,32 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_two_oid = {
|
||||
fs::write(repository.path().join("file two.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -204,7 +205,7 @@ async fn forcepush_allowed() {
|
||||
{
|
||||
fs::write(repository.path().join("file three.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -212,18 +213,18 @@ async fn forcepush_allowed() {
|
||||
{
|
||||
fs::write(repository.path().join("file four.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit four", None, false)
|
||||
.create_commit(project, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.squash(*project_id, branch_id, commit_two_oid)
|
||||
.squash(project, branch_id, commit_two_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -247,24 +248,24 @@ async fn forcepush_allowed() {
|
||||
async fn forcepush_forbidden() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch_id,
|
||||
allow_rebasing: Some(false),
|
||||
@ -277,20 +278,20 @@ async fn forcepush_forbidden() {
|
||||
{
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_two_oid = {
|
||||
fs::write(repository.path().join("file two.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -298,7 +299,7 @@ async fn forcepush_forbidden() {
|
||||
{
|
||||
fs::write(repository.path().join("file three.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -306,14 +307,14 @@ async fn forcepush_forbidden() {
|
||||
{
|
||||
fs::write(repository.path().join("file four.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit four", None, false)
|
||||
.create_commit(project, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
controller
|
||||
.squash(*project_id, branch_id, commit_two_oid)
|
||||
.squash(project, branch_id, commit_two_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
@ -325,32 +326,32 @@ async fn forcepush_forbidden() {
|
||||
async fn root_forbidden() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one_oid = {
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
controller
|
||||
.squash(*project_id, branch_id, commit_one_oid)
|
||||
.squash(project, branch_id, commit_one_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
|
@ -7,19 +7,19 @@ use crate::suite::virtual_branches::Test;
|
||||
#[tokio::test]
|
||||
async fn should_unapply_with_commits() {
|
||||
let Test {
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
repository,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -29,7 +29,7 @@ async fn should_unapply_with_commits() {
|
||||
)
|
||||
.unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "test", None, false)
|
||||
.create_commit(project, branch_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -42,7 +42,7 @@ async fn should_unapply_with_commits() {
|
||||
|
||||
controller
|
||||
.unapply_ownership(
|
||||
*project_id,
|
||||
project,
|
||||
&"file.txt:1-5,7-11"
|
||||
.parse::<BranchOwnershipClaims>()
|
||||
.unwrap(),
|
||||
@ -51,7 +51,7 @@ async fn should_unapply_with_commits() {
|
||||
.unwrap_or_else(|err| panic!("{err:?}"));
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -4,25 +4,25 @@ use super::*;
|
||||
async fn undo_commit_simple() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
let _commit1_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -30,24 +30,24 @@ async fn undo_commit_simple() {
|
||||
fs::write(repository.path().join("file2.txt"), "content2").unwrap();
|
||||
fs::write(repository.path().join("file3.txt"), "content3").unwrap();
|
||||
let commit2_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// create commit
|
||||
fs::write(repository.path().join("file4.txt"), "content4").unwrap();
|
||||
let _commit3_id = controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.undo_commit(*project_id, branch_id, commit2_id)
|
||||
.undo_commit(project, branch_id, commit2_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -8,7 +8,7 @@ mod applied_branch {
|
||||
async fn conflicts_with_uncommitted_work() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -24,14 +24,14 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
// make a branch that conflicts with the remote branch, but doesn't know about it yet
|
||||
controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -40,12 +40,12 @@ mod applied_branch {
|
||||
|
||||
let unapplied_branch = {
|
||||
// fetch remote
|
||||
let unapplied_branches = controller.update_base_branch(*project_id).await.unwrap();
|
||||
let unapplied_branches = controller.update_base_branch(project).await.unwrap();
|
||||
assert_eq!(unapplied_branches.len(), 1);
|
||||
|
||||
// should stash conflicting branch
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
@ -54,10 +54,10 @@ mod applied_branch {
|
||||
{
|
||||
// applying the branch should produce conflict markers
|
||||
controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].conflicted);
|
||||
assert!(branches[0].base_current);
|
||||
@ -73,7 +73,7 @@ mod applied_branch {
|
||||
async fn commited_conflict_not_pushed() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -89,7 +89,7 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -97,25 +97,25 @@ 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_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "conflicting commit", None, false)
|
||||
.create_commit(project, branch_id, "conflicting commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let unapplied_branch = {
|
||||
// when fetching remote
|
||||
let unapplied_branches = controller.update_base_branch(*project_id).await.unwrap();
|
||||
let unapplied_branches = controller.update_base_branch(project).await.unwrap();
|
||||
assert_eq!(unapplied_branches.len(), 1);
|
||||
|
||||
// should stash the branch.
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
@ -124,10 +124,10 @@ mod applied_branch {
|
||||
{
|
||||
// applying the branch should produce conflict markers
|
||||
controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].conflicted);
|
||||
assert!(branches[0].base_current);
|
||||
@ -144,7 +144,7 @@ mod applied_branch {
|
||||
async fn commited_conflict_pushed() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -160,7 +160,7 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -168,30 +168,30 @@ 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_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "conflicting commit", None, false)
|
||||
.create_commit(project, branch_id, "conflicting commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let unapplied_branch = {
|
||||
// when fetching remote
|
||||
let unapplied_branches = controller.update_base_branch(*project_id).await.unwrap();
|
||||
let unapplied_branches = controller.update_base_branch(project).await.unwrap();
|
||||
assert_eq!(unapplied_branches.len(), 1);
|
||||
|
||||
// should stash the branch.
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
@ -200,10 +200,10 @@ mod applied_branch {
|
||||
{
|
||||
// applying the branch should produce conflict markers
|
||||
controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].conflicted);
|
||||
assert!(branches[0].base_current);
|
||||
@ -220,7 +220,7 @@ mod applied_branch {
|
||||
async fn commited_conflict_not_pushed_fixed_with_more_work() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -236,7 +236,7 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -244,13 +244,13 @@ 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_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "conflicting commit", None, false)
|
||||
.create_commit(project, branch_id, "conflicting commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -259,12 +259,12 @@ mod applied_branch {
|
||||
|
||||
let unapplied_branch = {
|
||||
// when fetching remote
|
||||
let unapplied_branches = controller.update_base_branch(*project_id).await.unwrap();
|
||||
let unapplied_branches = controller.update_base_branch(project).await.unwrap();
|
||||
assert_eq!(unapplied_branches.len(), 1);
|
||||
|
||||
// should rebase upstream, and leave uncommited file as is
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
@ -273,10 +273,10 @@ mod applied_branch {
|
||||
{
|
||||
// applying the branch should produce conflict markers
|
||||
controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].conflicted);
|
||||
assert!(branches[0].base_current);
|
||||
@ -293,7 +293,7 @@ mod applied_branch {
|
||||
async fn commited_conflict_pushed_fixed_with_more_work() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -309,7 +309,7 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -317,13 +317,13 @@ 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_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "conflicting commit", None, false)
|
||||
.create_commit(project, branch_id, "conflicting commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -332,12 +332,12 @@ mod applied_branch {
|
||||
|
||||
let unapplied_branch = {
|
||||
// when fetching remote
|
||||
let unapplied_branches = controller.update_base_branch(*project_id).await.unwrap();
|
||||
let unapplied_branches = controller.update_base_branch(project).await.unwrap();
|
||||
assert_eq!(unapplied_branches.len(), 1);
|
||||
|
||||
// should merge upstream, and leave uncommited file as is.
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
@ -346,10 +346,10 @@ mod applied_branch {
|
||||
{
|
||||
// applying the branch should produce conflict markers
|
||||
controller
|
||||
.create_virtual_branch_from_branch(*project_id, &unapplied_branch)
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].conflicted);
|
||||
assert!(branches[0].base_current);
|
||||
@ -369,6 +369,7 @@ mod applied_branch {
|
||||
async fn force_push_ok() {
|
||||
let Test {
|
||||
repository,
|
||||
project,
|
||||
project_id,
|
||||
controller,
|
||||
projects,
|
||||
@ -394,24 +395,24 @@ mod applied_branch {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = {
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file2.txt"), "no conflict").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "no conflicts", None, false)
|
||||
.create_commit(project, branch_id, "no conflicts", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -422,12 +423,12 @@ mod applied_branch {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// rebases branch, since the branch is pushed and force pushing is
|
||||
// allowed
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -444,7 +445,7 @@ mod applied_branch {
|
||||
async fn force_push_not_ok() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -460,24 +461,24 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = {
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file2.txt"), "no conflict").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "no conflicts", None, false)
|
||||
.create_commit(project, branch_id, "no conflicts", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -488,7 +489,7 @@ mod applied_branch {
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch_id,
|
||||
allow_rebasing: Some(false),
|
||||
@ -500,11 +501,11 @@ mod applied_branch {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// creates a merge commit, since the branch is pushed
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -524,7 +525,7 @@ mod applied_branch {
|
||||
async fn no_conflicts() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -540,20 +541,20 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = {
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file2.txt"), "no conflict").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "no conflicts", None, false)
|
||||
.create_commit(project, branch_id, "no conflicts", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -564,11 +565,11 @@ mod applied_branch {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// just rebases branch
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -591,7 +592,7 @@ mod applied_branch {
|
||||
async fn integrated_commit_plus_work() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -603,32 +604,32 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
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_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "second").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "second", None, false)
|
||||
.create_commit(project, branch_id, "second", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
// merge branch upstream
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -647,11 +648,11 @@ mod applied_branch {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// should remove integrated commit, but leave non integrated work as is
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -674,7 +675,7 @@ mod applied_branch {
|
||||
async fn integrated_with_locked_conflicting_hunks() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -698,14 +699,14 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// branch has no conflict
|
||||
let branch_id = {
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -716,7 +717,7 @@ mod applied_branch {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "fourth", None, false)
|
||||
.create_commit(project, branch_id, "fourth", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -725,7 +726,7 @@ mod applied_branch {
|
||||
|
||||
// push the branch
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -738,24 +739,19 @@ mod applied_branch {
|
||||
|
||||
{
|
||||
// merge branch remotely
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0[0]
|
||||
.clone();
|
||||
let branch = controller.list_virtual_branches(project).await.unwrap().0[0].clone();
|
||||
repository.merge(&branch.upstream.as_ref().unwrap().name);
|
||||
}
|
||||
|
||||
repository.fetch();
|
||||
|
||||
let unapplied_refname = {
|
||||
let unapplied_refnames = controller.update_base_branch(*project_id).await.unwrap();
|
||||
let unapplied_refnames = controller.update_base_branch(project).await.unwrap();
|
||||
assert_eq!(unapplied_refnames.len(), 1);
|
||||
|
||||
// removes integrated commit, leaves non commited work as is
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert_eq!(
|
||||
fs::read_to_string(repository.path().join("file.txt")).unwrap(),
|
||||
@ -768,13 +764,13 @@ mod applied_branch {
|
||||
{
|
||||
controller
|
||||
.create_virtual_branch_from_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&git::Refname::from_str(unapplied_refname.as_str()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].active);
|
||||
assert!(branches[0].conflicted);
|
||||
@ -792,6 +788,7 @@ mod applied_branch {
|
||||
async fn integrated_with_locked_hunks() {
|
||||
let Test {
|
||||
repository,
|
||||
project,
|
||||
project_id,
|
||||
controller,
|
||||
projects,
|
||||
@ -807,20 +804,20 @@ mod applied_branch {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = {
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "first").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "first", None, false)
|
||||
.create_commit(project, branch_id, "first", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -828,7 +825,7 @@ mod applied_branch {
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -837,23 +834,18 @@ mod applied_branch {
|
||||
|
||||
{
|
||||
// push and merge branch remotely
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0[0]
|
||||
.clone();
|
||||
let branch = controller.list_virtual_branches(project).await.unwrap().0[0].clone();
|
||||
repository.merge(&branch.upstream.as_ref().unwrap().name);
|
||||
}
|
||||
|
||||
repository.fetch();
|
||||
|
||||
{
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// removes integrated commit, leaves non commited work as is
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -867,27 +859,27 @@ mod applied_branch {
|
||||
async fn integrated_with_non_locked_hunks() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
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_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "first").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "first", None, false)
|
||||
.create_commit(project, branch_id, "first", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -895,7 +887,7 @@ mod applied_branch {
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -904,23 +896,18 @@ mod applied_branch {
|
||||
|
||||
{
|
||||
// push and merge branch remotely
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0[0]
|
||||
.clone();
|
||||
let branch = controller.list_virtual_branches(project).await.unwrap().0[0].clone();
|
||||
repository.merge(&branch.upstream.as_ref().unwrap().name);
|
||||
}
|
||||
|
||||
repository.fetch();
|
||||
|
||||
{
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// removes integrated commit, leaves non commited work as is
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -934,7 +921,7 @@ mod applied_branch {
|
||||
async fn all_integrated() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -950,32 +937,32 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
// make a branch that conflicts with the remote branch, but doesn't know about it yet
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file.txt"), "second").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "second", None, false)
|
||||
.create_commit(project, branch_id, "second", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
};
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// just removes integrated branch
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
}
|
||||
}
|
||||
@ -984,7 +971,7 @@ mod applied_branch {
|
||||
async fn integrate_work_while_being_behind() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -1000,12 +987,12 @@ mod applied_branch {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -1013,33 +1000,28 @@ mod applied_branch {
|
||||
// open pr
|
||||
fs::write(repository.path().join("file2.txt"), "new file").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "second", None, false)
|
||||
.create_commit(project, branch_id, "second", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
{
|
||||
// merge pr
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0[0]
|
||||
.clone();
|
||||
let branch = controller.list_virtual_branches(project).await.unwrap().0[0].clone();
|
||||
repository.merge(&branch.upstream.as_ref().unwrap().name);
|
||||
repository.fetch();
|
||||
}
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// just removes integrated branch
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
}
|
||||
}
|
||||
@ -1050,7 +1032,7 @@ mod applied_branch {
|
||||
async fn should_not_get_confused_by_commits_in_other_branches() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
@ -1063,24 +1045,24 @@ mod applied_branch {
|
||||
repository.reset_hard(Some(first_commit_oid));
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
fs::write(repository.path().join("file-3.txt"), "three").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_1_id, "third", None, false)
|
||||
.create_commit(project, branch_1_id, "third", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_2_id = controller
|
||||
.create_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -1092,32 +1074,27 @@ mod applied_branch {
|
||||
fs::write(repository.path().join("file-4.txt"), "four").unwrap();
|
||||
|
||||
controller
|
||||
.create_commit(*project_id, branch_2_id, "fourth", None, false)
|
||||
.create_commit(project, branch_2_id, "fourth", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_2_id, false, None)
|
||||
.push_virtual_branch(project, branch_2_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0[1]
|
||||
.clone();
|
||||
let branch = controller.list_virtual_branches(project).await.unwrap().0[1].clone();
|
||||
|
||||
repository.merge(&branch.upstream.as_ref().unwrap().name);
|
||||
repository.fetch();
|
||||
|
||||
// TODO(mg): Figure out why test fails without listing first.
|
||||
controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
controller.list_virtual_branches(project).await.unwrap();
|
||||
controller.update_base_branch(project).await.unwrap();
|
||||
|
||||
// Verify we have only the first branch left, and that no files
|
||||
// are present.
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].files.len(), 0);
|
||||
}
|
||||
|
@ -6,25 +6,25 @@ use super::*;
|
||||
async fn head() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -32,7 +32,7 @@ async fn head() {
|
||||
{
|
||||
fs::write(repository.path().join("file two.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -40,7 +40,7 @@ async fn head() {
|
||||
let commit_three_oid = {
|
||||
fs::write(repository.path().join("file three.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -48,17 +48,12 @@ async fn head() {
|
||||
let before_change_id = &commit_three.change_id();
|
||||
|
||||
controller
|
||||
.update_commit_message(
|
||||
*project_id,
|
||||
branch_id,
|
||||
commit_three_oid,
|
||||
"commit three updated",
|
||||
)
|
||||
.update_commit_message(project, branch_id, commit_three_oid, "commit three updated")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -89,25 +84,25 @@ async fn head() {
|
||||
async fn middle() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -115,7 +110,7 @@ async fn middle() {
|
||||
let commit_two_oid = {
|
||||
fs::write(repository.path().join("file two.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -123,18 +118,18 @@ async fn middle() {
|
||||
{
|
||||
fs::write(repository.path().join("file three.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.update_commit_message(*project_id, branch_id, commit_two_oid, "commit two updated")
|
||||
.update_commit_message(project, branch_id, commit_two_oid, "commit two updated")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -158,13 +153,14 @@ async fn forcepush_allowed() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
projects,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -177,30 +173,30 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one_oid = {
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.update_commit_message(*project_id, branch_id, commit_one_oid, "commit one updated")
|
||||
.update_commit_message(project, branch_id, commit_one_oid, "commit one updated")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -221,24 +217,24 @@ async fn forcepush_allowed() {
|
||||
async fn forcepush_forbidden() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
*project_id,
|
||||
project,
|
||||
branch::BranchUpdateRequest {
|
||||
id: branch_id,
|
||||
allow_rebasing: Some(false),
|
||||
@ -251,19 +247,19 @@ async fn forcepush_forbidden() {
|
||||
let commit_one_oid = {
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.push_virtual_branch(project, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
controller
|
||||
.update_commit_message(*project_id, branch_id, commit_one_oid, "commit one updated",)
|
||||
.update_commit_message(project, branch_id, commit_one_oid, "commit one updated",)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
@ -275,25 +271,25 @@ async fn forcepush_forbidden() {
|
||||
async fn root() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one_oid = {
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -301,7 +297,7 @@ async fn root() {
|
||||
{
|
||||
fs::write(repository.path().join("file two.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.create_commit(project, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -309,18 +305,18 @@ async fn root() {
|
||||
{
|
||||
fs::write(repository.path().join("file three.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.create_commit(project, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.update_commit_message(*project_id, branch_id, commit_one_oid, "commit one updated")
|
||||
.update_commit_message(project, branch_id, commit_one_oid, "commit one updated")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -343,32 +339,32 @@ async fn root() {
|
||||
async fn empty() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one_oid = {
|
||||
fs::write(repository.path().join("file one.txt"), "").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.create_commit(project, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
controller
|
||||
.update_commit_message(*project_id, branch_id, commit_one_oid, "",)
|
||||
.update_commit_message(project, branch_id, commit_one_oid, "",)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string(),
|
||||
|
@ -4,18 +4,18 @@ use super::*;
|
||||
async fn detect_upstream_commits() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -23,7 +23,7 @@ async fn detect_upstream_commits() {
|
||||
// create first commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -32,14 +32,14 @@ async fn detect_upstream_commits() {
|
||||
// create second commit
|
||||
fs::write(repository.path().join("file.txt"), "content2").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
// push
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch1_id, false, None)
|
||||
.push_virtual_branch(project, branch1_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -47,14 +47,14 @@ async fn detect_upstream_commits() {
|
||||
// create third commit
|
||||
fs::write(repository.path().join("file.txt"), "content3").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
// should correctly detect pushed commits
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 3);
|
||||
@ -71,18 +71,18 @@ async fn detect_upstream_commits() {
|
||||
async fn detect_integrated_commits() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(project, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -90,7 +90,7 @@ async fn detect_integrated_commits() {
|
||||
// create first commit
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -99,21 +99,21 @@ async fn detect_integrated_commits() {
|
||||
// create second commit
|
||||
fs::write(repository.path().join("file.txt"), "content2").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
// push
|
||||
controller
|
||||
.push_virtual_branch(*project_id, branch1_id, false, None)
|
||||
.push_virtual_branch(project, branch1_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
// merge branch upstream
|
||||
let branch = controller
|
||||
.list_virtual_branches(*project_id)
|
||||
.list_virtual_branches(project)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -128,14 +128,14 @@ async fn detect_integrated_commits() {
|
||||
// create third commit
|
||||
fs::write(repository.path().join("file.txt"), "content3").unwrap();
|
||||
controller
|
||||
.create_commit(*project_id, branch1_id, "commit", None, false)
|
||||
.create_commit(project, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
// should correctly detect pushed commits
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 3);
|
||||
|
@ -5,14 +5,14 @@ use super::*;
|
||||
async fn should_fail_on_incorrect_branch() {
|
||||
let Test {
|
||||
repository,
|
||||
project_id,
|
||||
project,
|
||||
controller,
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
let branch_name: git::LocalRefname = "refs/heads/somebranch".parse().unwrap();
|
||||
repository.checkout(&branch_name);
|
||||
let result = controller.list_virtual_branches(*project_id).await;
|
||||
let result = controller.list_virtual_branches(project).await;
|
||||
|
||||
let err = result.unwrap_err();
|
||||
assert_eq!(
|
||||
|
@ -29,9 +29,10 @@ pub mod commands {
|
||||
ownership: Option<BranchOwnershipClaims>,
|
||||
run_hooks: bool,
|
||||
) -> Result<String, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
.create_commit(project_id, branch, message, ownership.as_ref(), run_hooks)
|
||||
.create_commit(&project, branch, message, ownership.as_ref(), run_hooks)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(oid.to_string())
|
||||
@ -43,9 +44,10 @@ pub mod commands {
|
||||
handle: AppHandle,
|
||||
project_id: ProjectId,
|
||||
) -> Result<VirtualBranches, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let (branches, skipped_files) = handle
|
||||
.state::<Controller>()
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(&project)
|
||||
.await?;
|
||||
|
||||
let proxy = handle.state::<assets::Proxy>();
|
||||
@ -63,9 +65,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
branch: branch::BranchCreateRequest,
|
||||
) -> Result<BranchId, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_id = handle
|
||||
.state::<Controller>()
|
||||
.create_virtual_branch(project_id, &branch)
|
||||
.create_virtual_branch(&project, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(branch_id)
|
||||
@ -78,9 +81,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
branch: git::Refname,
|
||||
) -> Result<BranchId, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_id = handle
|
||||
.state::<Controller>()
|
||||
.create_virtual_branch_from_branch(project_id, &branch)
|
||||
.create_virtual_branch_from_branch(&project, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(branch_id)
|
||||
@ -93,9 +97,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
branch: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.integrate_upstream_commits(project_id, branch)
|
||||
.integrate_upstream_commits(&project, branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -107,9 +112,10 @@ pub mod commands {
|
||||
handle: AppHandle,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Option<BaseBranch>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
if let Ok(base_branch) = handle
|
||||
.state::<Controller>()
|
||||
.get_base_branch_data(project_id)
|
||||
.get_base_branch_data(&project)
|
||||
.await
|
||||
{
|
||||
let proxy = handle.state::<assets::Proxy>();
|
||||
@ -127,12 +133,13 @@ pub mod commands {
|
||||
branch: &str,
|
||||
push_remote: Option<&str>, // optional different name of a remote to push to (defaults to same as the branch)
|
||||
) -> Result<BaseBranch, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_name = format!("refs/remotes/{}", branch)
|
||||
.parse()
|
||||
.context("Invalid branch name")?;
|
||||
let base_branch = handle
|
||||
.state::<Controller>()
|
||||
.set_base_branch(project_id, &branch_name)
|
||||
.set_base_branch(&project, &branch_name)
|
||||
.await?;
|
||||
let base_branch = handle
|
||||
.state::<assets::Proxy>()
|
||||
@ -143,7 +150,7 @@ pub mod commands {
|
||||
if let Some(push_remote) = push_remote {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.set_target_push_remote(project_id, push_remote)
|
||||
.set_target_push_remote(&project, push_remote)
|
||||
.await?;
|
||||
}
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -156,9 +163,10 @@ pub mod commands {
|
||||
handle: AppHandle,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<ReferenceName>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let unapplied_branches = handle
|
||||
.state::<Controller>()
|
||||
.update_base_branch(project_id)
|
||||
.update_base_branch(&project)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(unapplied_branches)
|
||||
@ -171,9 +179,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
branch: branch::BranchUpdateRequest,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.update_virtual_branch(project_id, branch)
|
||||
.update_virtual_branch(&project, branch)
|
||||
.await?;
|
||||
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -187,9 +196,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.delete_virtual_branch(project_id, branch_id)
|
||||
.delete_virtual_branch(&project, branch_id)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -203,9 +213,10 @@ pub mod commands {
|
||||
branch: BranchId,
|
||||
name_conflict_resolution: NameConflitResolution,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.convert_to_real_branch(project_id, branch, name_conflict_resolution)
|
||||
.convert_to_real_branch(&project, branch, name_conflict_resolution)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -218,9 +229,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
ownership: BranchOwnershipClaims,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.unapply_ownership(project_id, &ownership)
|
||||
.unapply_ownership(&project, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -233,6 +245,7 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
files: &str,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
// convert files to Vec<String>
|
||||
let files = files
|
||||
.split('\n')
|
||||
@ -240,7 +253,7 @@ pub mod commands {
|
||||
.collect::<Vec<String>>();
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.reset_files(project_id, &files)
|
||||
.reset_files(&project, &files)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -254,9 +267,10 @@ pub mod commands {
|
||||
branch_id: BranchId,
|
||||
with_force: bool,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.push_virtual_branch(project_id, branch_id, with_force, Some(Some(branch_id)))
|
||||
.push_virtual_branch(&project, branch_id, with_force, Some(Some(branch_id)))
|
||||
.await
|
||||
.map_err(|err| err.context(Code::Unknown))?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
@ -270,9 +284,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
branch: git::RemoteRefname,
|
||||
) -> Result<bool, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
Ok(handle
|
||||
.state::<Controller>()
|
||||
.can_apply_remote_branch(project_id, &branch)
|
||||
.can_apply_remote_branch(&project, &branch)
|
||||
.await?)
|
||||
}
|
||||
|
||||
@ -283,10 +298,11 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
commit_oid: String,
|
||||
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.list_remote_commit_files(project_id, commit_oid)
|
||||
.list_remote_commit_files(&project, commit_oid)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
@ -299,10 +315,11 @@ pub mod commands {
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: String,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let target_commit_oid = git2::Oid::from_str(&target_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.reset_virtual_branch(project_id, branch_id, target_commit_oid)
|
||||
.reset_virtual_branch(&project, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -317,10 +334,11 @@ pub mod commands {
|
||||
commit_oid: String,
|
||||
ownership: BranchOwnershipClaims,
|
||||
) -> Result<String, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
.amend(project_id, branch_id, commit_oid, &ownership)
|
||||
.amend(&project, branch_id, commit_oid, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(oid.to_string())
|
||||
@ -336,12 +354,13 @@ pub mod commands {
|
||||
to_commit_oid: String,
|
||||
ownership: BranchOwnershipClaims,
|
||||
) -> Result<String, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let from_commit_oid = git2::Oid::from_str(&from_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
let to_commit_oid = git2::Oid::from_str(&to_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
.move_commit_file(
|
||||
project_id,
|
||||
&project,
|
||||
branch_id,
|
||||
from_commit_oid,
|
||||
to_commit_oid,
|
||||
@ -360,10 +379,11 @@ pub mod commands {
|
||||
branch_id: BranchId,
|
||||
commit_oid: String,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.undo_commit(project_id, branch_id, commit_oid)
|
||||
.undo_commit(&project, branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -378,10 +398,11 @@ pub mod commands {
|
||||
commit_oid: String,
|
||||
offset: i32,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.insert_blank_commit(project_id, branch_id, commit_oid, offset)
|
||||
.insert_blank_commit(&project, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -396,10 +417,11 @@ pub mod commands {
|
||||
commit_oid: String,
|
||||
offset: i32,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.reorder_commit(project_id, branch_id, commit_oid, offset)
|
||||
.reorder_commit(&project, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -411,9 +433,10 @@ pub mod commands {
|
||||
handle: tauri::AppHandle,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<RemoteBranch>, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branches = handle
|
||||
.state::<Controller>()
|
||||
.list_remote_branches(project_id)
|
||||
.list_remote_branches(project)
|
||||
.await?;
|
||||
Ok(branches)
|
||||
}
|
||||
@ -425,9 +448,10 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
refname: git::Refname,
|
||||
) -> Result<RemoteBranchData, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_data = handle
|
||||
.state::<Controller>()
|
||||
.get_remote_branch_data(project_id, &refname)
|
||||
.get_remote_branch_data(&project, &refname)
|
||||
.await?;
|
||||
let branch_data = handle
|
||||
.state::<assets::Proxy>()
|
||||
@ -444,10 +468,11 @@ pub mod commands {
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: String,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let target_commit_oid = git2::Oid::from_str(&target_commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.squash(project_id, branch_id, target_commit_oid)
|
||||
.squash(&project, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -460,10 +485,11 @@ pub mod commands {
|
||||
project_id: ProjectId,
|
||||
action: Option<String>,
|
||||
) -> Result<BaseBranch, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let base_branch = handle
|
||||
.state::<Controller>()
|
||||
.fetch_from_remotes(
|
||||
project_id,
|
||||
&project,
|
||||
Some(action.unwrap_or_else(|| "unknown".to_string())),
|
||||
)
|
||||
.await?;
|
||||
@ -479,10 +505,11 @@ pub mod commands {
|
||||
commit_oid: String,
|
||||
target_branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.move_commit(project_id, target_branch_id, commit_oid)
|
||||
.move_commit(&project, target_branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
@ -497,10 +524,11 @@ pub mod commands {
|
||||
commit_oid: String,
|
||||
message: &str,
|
||||
) -> Result<(), Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let commit_oid = git2::Oid::from_str(&commit_oid).map_err(|e| anyhow!(e))?;
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.update_commit_message(project_id, branch_id, commit_oid, message)
|
||||
.update_commit_message(&project, branch_id, commit_oid, message)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
|
@ -85,15 +85,19 @@ impl Handler {
|
||||
|
||||
#[instrument(skip(self, project_id))]
|
||||
async fn calculate_virtual_branches(&self, project_id: ProjectId) -> Result<()> {
|
||||
let project = self
|
||||
.projects
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
match self
|
||||
.vbranch_controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(&project)
|
||||
.await
|
||||
{
|
||||
Ok((branches, skipped_files)) => {
|
||||
let branches = self.assets_proxy.proxy_virtual_branches(branches).await;
|
||||
self.emit_app_event(Change::VirtualBranches {
|
||||
project_id,
|
||||
project_id: project.id,
|
||||
virtual_branches: VirtualBranches {
|
||||
branches,
|
||||
skipped_files,
|
||||
@ -142,21 +146,13 @@ impl Handler {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn git_file_change(
|
||||
&self,
|
||||
path: impl Into<PathBuf>,
|
||||
project_id: ProjectId,
|
||||
) -> Result<()> {
|
||||
self.git_files_change(vec![path.into()], project_id).await
|
||||
}
|
||||
|
||||
pub async fn git_files_change(&self, paths: Vec<PathBuf>, project_id: ProjectId) -> Result<()> {
|
||||
let project = self
|
||||
.projects
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
let open_projects_repository = || {
|
||||
project_repository::Repository::open(&project)
|
||||
project_repository::Repository::open(&project.clone())
|
||||
.context("failed to open project repository for project")
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user