mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 22:03:30 +03:00
Merge pull request #3885 from gitbutlerapp/rust-remote-tweaks-for-byron
Tweaks to remotes code
This commit is contained in:
commit
1abb464845
@ -119,7 +119,7 @@ impl Project {
|
||||
|
||||
let branch_tree_id = branch_tree_builder.write()?;
|
||||
branches_tree_builder.insert(
|
||||
&branch.id.to_string(),
|
||||
branch.id.to_string(),
|
||||
branch_tree_id,
|
||||
FileMode::Tree.into(),
|
||||
)?;
|
||||
|
@ -604,13 +604,11 @@ impl Repository {
|
||||
}
|
||||
|
||||
pub fn remotes(&self) -> Result<Vec<String>> {
|
||||
self.git_repository.remotes().map_err(anyhow::Error::from)
|
||||
Ok(self.git_repository.remotes()?)
|
||||
}
|
||||
|
||||
pub fn add_remote(&self, name: &str, url: &str) -> Result<()> {
|
||||
self.git_repository
|
||||
.add_remote(name, url)
|
||||
.map_err(anyhow::Error::from)
|
||||
Ok(self.git_repository.add_remote(name, url)?)
|
||||
}
|
||||
|
||||
pub fn repo(&self) -> &git2::Repository {
|
||||
|
@ -160,7 +160,7 @@ impl Controller {
|
||||
Ok(updated)
|
||||
}
|
||||
|
||||
pub fn get(&self, id: &ProjectId) -> Result<Project, GetError> {
|
||||
pub fn get(&self, id: ProjectId) -> Result<Project, GetError> {
|
||||
let project = self.projects_storage.get(id).map_err(|error| match error {
|
||||
super::storage::Error::NotFound => GetError::NotFound,
|
||||
error => GetError::Other(error.into()),
|
||||
@ -200,7 +200,7 @@ impl Controller {
|
||||
self.projects_storage.list().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub async fn delete(&self, id: &ProjectId) -> Result<(), Error> {
|
||||
pub async fn delete(&self, id: ProjectId) -> Result<(), Error> {
|
||||
let project = match self.projects_storage.get(id) {
|
||||
Ok(project) => Ok(project),
|
||||
Err(super::storage::Error::NotFound) => return Ok(()),
|
||||
@ -208,11 +208,11 @@ impl Controller {
|
||||
}?;
|
||||
|
||||
if let Some(watchers) = &self.watchers {
|
||||
watchers.stop(*id).await;
|
||||
watchers.stop(id).await;
|
||||
}
|
||||
|
||||
self.projects_storage
|
||||
.purge(&project.id)
|
||||
.purge(project.id)
|
||||
.map_err(anyhow::Error::from)?;
|
||||
|
||||
if let Err(error) = std::fs::remove_dir_all(
|
||||
@ -238,7 +238,7 @@ impl Controller {
|
||||
|
||||
pub fn get_local_config(
|
||||
&self,
|
||||
id: &ProjectId,
|
||||
id: ProjectId,
|
||||
key: &str,
|
||||
) -> Result<Option<String>, ConfigError> {
|
||||
let project = self.projects_storage.get(id).map_err(|error| match error {
|
||||
@ -255,7 +255,7 @@ impl Controller {
|
||||
|
||||
pub fn set_local_config(
|
||||
&self,
|
||||
id: &ProjectId,
|
||||
id: ProjectId,
|
||||
key: &str,
|
||||
value: &str,
|
||||
) -> Result<(), ConfigError> {
|
||||
|
@ -73,9 +73,9 @@ impl Storage {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self, id: &ProjectId) -> Result<project::Project, Error> {
|
||||
pub fn get(&self, id: ProjectId) -> Result<project::Project, Error> {
|
||||
let projects = self.list()?;
|
||||
match projects.into_iter().find(|p| p.id == *id) {
|
||||
match projects.into_iter().find(|p| p.id == id) {
|
||||
Some(project) => Ok(project),
|
||||
None => Err(Error::NotFound),
|
||||
}
|
||||
@ -140,9 +140,9 @@ impl Storage {
|
||||
.clone())
|
||||
}
|
||||
|
||||
pub fn purge(&self, id: &ProjectId) -> Result<(), Error> {
|
||||
pub fn purge(&self, id: ProjectId) -> Result<(), Error> {
|
||||
let mut projects = self.list()?;
|
||||
if let Some(index) = projects.iter().position(|p| p.id == *id) {
|
||||
if let Some(index) = projects.iter().position(|p| p.id == id) {
|
||||
projects.remove(index);
|
||||
self.inner
|
||||
.write(PROJECTS_FILE, &serde_json::to_string_pretty(&projects)?)?;
|
||||
|
@ -14,22 +14,22 @@ impl Controller {
|
||||
Self { projects }
|
||||
}
|
||||
|
||||
pub async fn remotes(&self, project_id: &ProjectId) -> Result<Vec<String>, Error> {
|
||||
pub async fn remotes(&self, project_id: ProjectId) -> Result<Vec<String>, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
|
||||
project_repository.remotes().map_err(Into::into)
|
||||
Ok(project_repository.remotes()?)
|
||||
}
|
||||
|
||||
pub async fn add_remote(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
name: &str,
|
||||
url: &str,
|
||||
) -> Result<(), Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
|
||||
project_repository.add_remote(name, url).map_err(Into::into)
|
||||
Ok(project_repository.add_remote(name, url)?)
|
||||
}
|
||||
}
|
||||
|
@ -42,19 +42,19 @@ impl Controller {
|
||||
}
|
||||
}
|
||||
|
||||
async fn inner(&self, project_id: &ProjectId) -> ControllerInner {
|
||||
async fn inner(&self, project_id: ProjectId) -> ControllerInner {
|
||||
self.by_project_id
|
||||
.lock()
|
||||
.await
|
||||
.entry(*project_id)
|
||||
.entry(project_id)
|
||||
.or_insert_with(|| ControllerInner::new(&self.projects, &self.users, &self.helper))
|
||||
.clone()
|
||||
}
|
||||
|
||||
pub async fn create_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
message: &str,
|
||||
ownership: Option<&BranchOwnershipClaims>,
|
||||
run_hooks: bool,
|
||||
@ -67,7 +67,7 @@ impl Controller {
|
||||
|
||||
pub async fn can_apply_remote_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
branch_name: &git::RemoteRefname,
|
||||
) -> Result<bool, Error> {
|
||||
self.inner(project_id)
|
||||
@ -77,8 +77,8 @@ impl Controller {
|
||||
|
||||
pub async fn can_apply_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<bool, Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
@ -87,7 +87,7 @@ impl Controller {
|
||||
|
||||
pub async fn list_virtual_branches(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
) -> Result<(Vec<super::VirtualBranch>, Vec<git::diff::FileDiff>), Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
@ -97,7 +97,7 @@ impl Controller {
|
||||
|
||||
pub async fn create_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
create: &super::branch::BranchCreateRequest,
|
||||
) -> Result<BranchId, Error> {
|
||||
self.inner(project_id)
|
||||
@ -108,7 +108,7 @@ impl Controller {
|
||||
|
||||
pub async fn create_virtual_branch_from_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
branch: &git::Refname,
|
||||
) -> Result<BranchId, Error> {
|
||||
self.inner(project_id)
|
||||
@ -117,7 +117,7 @@ impl Controller {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_base_branch_data(&self, project_id: &ProjectId) -> Result<BaseBranch, Error> {
|
||||
pub async fn get_base_branch_data(&self, project_id: ProjectId) -> Result<BaseBranch, Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
.get_base_branch_data(project_id)
|
||||
@ -125,7 +125,7 @@ impl Controller {
|
||||
|
||||
pub async fn list_remote_commit_files(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||
self.inner(project_id)
|
||||
@ -135,7 +135,7 @@ impl Controller {
|
||||
|
||||
pub async fn set_base_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
target_branch: &git::RemoteRefname,
|
||||
) -> Result<super::BaseBranch, Error> {
|
||||
self.inner(project_id)
|
||||
@ -145,7 +145,7 @@ impl Controller {
|
||||
|
||||
pub async fn set_target_push_remote(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
push_remote: &str,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -155,8 +155,8 @@ impl Controller {
|
||||
|
||||
pub async fn integrate_upstream_commits(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
@ -164,7 +164,7 @@ impl Controller {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn update_base_branch(&self, project_id: &ProjectId) -> Result<(), Error> {
|
||||
pub async fn update_base_branch(&self, project_id: ProjectId) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
.update_base_branch(project_id)
|
||||
@ -173,7 +173,7 @@ impl Controller {
|
||||
|
||||
pub async fn update_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
branch_update: super::branch::BranchUpdateRequest,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -183,8 +183,8 @@ impl Controller {
|
||||
}
|
||||
pub async fn delete_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
@ -194,8 +194,8 @@ impl Controller {
|
||||
|
||||
pub async fn apply_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
@ -205,7 +205,7 @@ impl Controller {
|
||||
|
||||
pub async fn unapply_ownership(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -216,7 +216,7 @@ impl Controller {
|
||||
|
||||
pub async fn reset_files(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
files: &Vec<String>,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -227,8 +227,8 @@ impl Controller {
|
||||
|
||||
pub async fn amend(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<git::Oid, Error> {
|
||||
@ -240,8 +240,8 @@ impl Controller {
|
||||
|
||||
pub async fn move_commit_file(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
from_commit_oid: git::Oid,
|
||||
to_commit_oid: git::Oid,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
@ -260,8 +260,8 @@ impl Controller {
|
||||
|
||||
pub async fn undo_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -272,8 +272,8 @@ impl Controller {
|
||||
|
||||
pub async fn insert_blank_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
offset: i32,
|
||||
) -> Result<(), Error> {
|
||||
@ -285,8 +285,8 @@ impl Controller {
|
||||
|
||||
pub async fn reorder_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
offset: i32,
|
||||
) -> Result<(), Error> {
|
||||
@ -298,8 +298,8 @@ impl Controller {
|
||||
|
||||
pub async fn reset_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -310,8 +310,8 @@ impl Controller {
|
||||
|
||||
pub async fn unapply_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
@ -321,8 +321,8 @@ impl Controller {
|
||||
|
||||
pub async fn push_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
with_force: bool,
|
||||
askpass: Option<Option<BranchId>>,
|
||||
) -> Result<(), Error> {
|
||||
@ -334,8 +334,8 @@ impl Controller {
|
||||
|
||||
pub async fn cherry_pick(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<Option<git::Oid>, Error> {
|
||||
self.inner(project_id)
|
||||
@ -346,7 +346,7 @@ impl Controller {
|
||||
|
||||
pub async fn list_remote_branches(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<super::RemoteBranch>, Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
@ -355,7 +355,7 @@ impl Controller {
|
||||
|
||||
pub async fn get_remote_branch_data(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
refname: &git::Refname,
|
||||
) -> Result<super::RemoteBranchData, Error> {
|
||||
self.inner(project_id)
|
||||
@ -365,8 +365,8 @@ impl Controller {
|
||||
|
||||
pub async fn squash(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -377,8 +377,8 @@ impl Controller {
|
||||
|
||||
pub async fn update_commit_message(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
message: &str,
|
||||
) -> Result<(), Error> {
|
||||
@ -390,7 +390,7 @@ impl Controller {
|
||||
|
||||
pub async fn fetch_from_remotes(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
askpass: Option<String>,
|
||||
) -> Result<BaseBranch, Error> {
|
||||
self.inner(project_id)
|
||||
@ -401,8 +401,8 @@ impl Controller {
|
||||
|
||||
pub async fn move_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
target_branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
target_branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
self.inner(project_id)
|
||||
@ -437,8 +437,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn create_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
message: &str,
|
||||
ownership: Option<&BranchOwnershipClaims>,
|
||||
run_hooks: bool,
|
||||
@ -469,7 +469,7 @@ impl ControllerInner {
|
||||
|
||||
pub fn can_apply_remote_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
branch_name: &git::RemoteRefname,
|
||||
) -> Result<bool, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
@ -482,8 +482,8 @@ impl ControllerInner {
|
||||
|
||||
pub fn can_apply_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<bool, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
@ -492,7 +492,7 @@ impl ControllerInner {
|
||||
|
||||
pub async fn list_virtual_branches(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
) -> Result<(Vec<super::VirtualBranch>, Vec<git::diff::FileDiff>), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
@ -503,7 +503,7 @@ impl ControllerInner {
|
||||
|
||||
pub async fn create_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
create: &super::branch::BranchCreateRequest,
|
||||
) -> Result<BranchId, Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -516,7 +516,7 @@ impl ControllerInner {
|
||||
|
||||
pub async fn create_virtual_branch_from_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
branch: &git::Refname,
|
||||
) -> Result<BranchId, Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -528,7 +528,7 @@ impl ControllerInner {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_base_branch_data(&self, project_id: &ProjectId) -> Result<BaseBranch, Error> {
|
||||
pub fn get_base_branch_data(&self, project_id: ProjectId) -> Result<BaseBranch, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
Ok(super::get_base_branch_data(&project_repository)?)
|
||||
@ -536,7 +536,7 @@ impl ControllerInner {
|
||||
|
||||
pub fn list_remote_commit_files(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
@ -547,7 +547,7 @@ impl ControllerInner {
|
||||
|
||||
pub fn set_base_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
target_branch: &git::RemoteRefname,
|
||||
) -> Result<super::BaseBranch, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
@ -561,7 +561,7 @@ impl ControllerInner {
|
||||
|
||||
pub fn set_target_push_remote(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
push_remote: &str,
|
||||
) -> Result<(), Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
@ -572,8 +572,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn integrate_upstream_commits(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
@ -586,7 +586,7 @@ impl ControllerInner {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn update_base_branch(&self, project_id: &ProjectId) -> Result<(), Error> {
|
||||
pub async fn update_base_branch(&self, project_id: ProjectId) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository, user| {
|
||||
@ -599,7 +599,7 @@ impl ControllerInner {
|
||||
|
||||
pub async fn update_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
branch_update: super::branch::BranchUpdateRequest,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -612,8 +612,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn delete_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
@ -624,8 +624,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn apply_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
@ -636,7 +636,7 @@ impl ControllerInner {
|
||||
|
||||
pub async fn unapply_ownership(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -651,7 +651,7 @@ impl ControllerInner {
|
||||
|
||||
pub async fn reset_files(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
ownership: &Vec<String>,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -666,8 +666,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn amend(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
) -> Result<git::Oid, Error> {
|
||||
@ -683,8 +683,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn move_commit_file(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
from_commit_oid: git::Oid,
|
||||
to_commit_oid: git::Oid,
|
||||
ownership: &BranchOwnershipClaims,
|
||||
@ -708,8 +708,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn undo_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -724,8 +724,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn insert_blank_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
offset: i32,
|
||||
) -> Result<(), Error> {
|
||||
@ -742,8 +742,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn reorder_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
offset: i32,
|
||||
) -> Result<(), Error> {
|
||||
@ -760,8 +760,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn reset_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -777,8 +777,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn unapply_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
@ -790,19 +790,17 @@ impl ControllerInner {
|
||||
|
||||
pub async fn push_virtual_branch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
with_force: bool,
|
||||
askpass: Option<Option<BranchId>>,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
let helper = self.helper.clone();
|
||||
let project_id = *project_id;
|
||||
let branch_id = *branch_id;
|
||||
self.with_verify_branch_async(&project_id, move |project_repository, _| {
|
||||
self.with_verify_branch_async(project_id, move |project_repository, _| {
|
||||
Ok(super::push(
|
||||
project_repository,
|
||||
&branch_id,
|
||||
branch_id,
|
||||
with_force,
|
||||
&helper,
|
||||
askpass,
|
||||
@ -814,8 +812,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn cherry_pick(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<Option<git::Oid>, Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -830,7 +828,7 @@ impl ControllerInner {
|
||||
|
||||
pub fn list_remote_branches(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<super::RemoteBranch>, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
@ -839,7 +837,7 @@ impl ControllerInner {
|
||||
|
||||
pub fn get_remote_branch_data(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
refname: &git::Refname,
|
||||
) -> Result<super::RemoteBranchData, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
@ -849,8 +847,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn squash(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -865,8 +863,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn update_commit_message(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
message: &str,
|
||||
) -> Result<(), Error> {
|
||||
@ -882,7 +880,7 @@ impl ControllerInner {
|
||||
|
||||
pub async fn fetch_from_remotes(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
askpass: Option<String>,
|
||||
) -> Result<BaseBranch, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
@ -928,7 +926,7 @@ impl ControllerInner {
|
||||
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()
|
||||
})
|
||||
@ -945,8 +943,8 @@ impl ControllerInner {
|
||||
|
||||
pub async fn move_commit(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
target_branch_id: &BranchId,
|
||||
project_id: ProjectId,
|
||||
target_branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
@ -964,7 +962,7 @@ impl ControllerInner {
|
||||
impl ControllerInner {
|
||||
fn with_verify_branch<T>(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
action: impl FnOnce(&project_repository::Repository, Option<&users::User>) -> Result<T, Error>,
|
||||
) -> Result<T, Error> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
@ -976,7 +974,7 @@ impl ControllerInner {
|
||||
|
||||
fn with_verify_branch_async<T: Send + 'static>(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
action: impl FnOnce(&project_repository::Repository, Option<&users::User>) -> Result<T, Error>
|
||||
+ Send
|
||||
+ 'static,
|
||||
|
@ -88,11 +88,11 @@ impl VirtualBranchesHandle {
|
||||
/// Gets the state of the given virtual branch.
|
||||
///
|
||||
/// Errors if the file cannot be read or written.
|
||||
pub fn get_branch(&self, id: &BranchId) -> Result<Branch, crate::reader::Error> {
|
||||
pub fn get_branch(&self, id: BranchId) -> Result<Branch, crate::reader::Error> {
|
||||
let virtual_branches = self.read_file()?;
|
||||
virtual_branches
|
||||
.branches
|
||||
.get(id)
|
||||
.get(&id)
|
||||
.cloned()
|
||||
.ok_or(crate::reader::Error::NotFound)
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ pub fn normalize_branch_name(name: &str) -> String {
|
||||
|
||||
pub fn apply_branch(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
user: Option<&users::User>,
|
||||
) -> Result<(), errors::ApplyBranchError> {
|
||||
if project_repository.is_resolving() {
|
||||
@ -235,7 +235,7 @@ pub fn apply_branch(
|
||||
Err(reader::Error::NotFound) => Err(errors::ApplyBranchError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
},
|
||||
)),
|
||||
Err(error) => Err(errors::ApplyBranchError::Other(error.into())),
|
||||
@ -444,7 +444,7 @@ pub fn apply_branch(
|
||||
.context("failed to merge trees")?;
|
||||
|
||||
if merge_index.has_conflicts() {
|
||||
return Err(errors::ApplyBranchError::BranchConflicts(*branch_id));
|
||||
return Err(errors::ApplyBranchError::BranchConflicts(branch_id));
|
||||
}
|
||||
|
||||
// apply the branch
|
||||
@ -610,7 +610,7 @@ pub fn reset_files(
|
||||
// to unapply a branch, we need to write the current tree out, then remove those file changes from the wd
|
||||
pub fn unapply_branch(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<Option<branch::Branch>, errors::UnapplyBranchError> {
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
|
||||
@ -620,7 +620,7 @@ pub fn unapply_branch(
|
||||
reader::Error::NotFound => {
|
||||
errors::UnapplyBranchError::BranchNotFound(errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
})
|
||||
}
|
||||
error => errors::UnapplyBranchError::Other(error.into()),
|
||||
@ -704,7 +704,7 @@ pub fn unapply_branch(
|
||||
// then check that out into the working directory
|
||||
let final_tree = applied_statuses
|
||||
.into_iter()
|
||||
.filter(|(branch, _)| &branch.id != branch_id)
|
||||
.filter(|(branch, _)| branch.id != branch_id)
|
||||
.fold(
|
||||
target_commit.tree().context("failed to get target tree"),
|
||||
|final_tree, status| {
|
||||
@ -1159,7 +1159,7 @@ pub fn create_virtual_branch(
|
||||
///
|
||||
pub fn integrate_upstream_commits(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
user: Option<&users::User>,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
conflicts::is_conflicting::<&Path>(project_repository, None)?;
|
||||
@ -1363,7 +1363,7 @@ pub fn update_branch(
|
||||
) -> Result<branch::Branch, errors::UpdateBranchError> {
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
let mut branch = vb_state
|
||||
.get_branch(&branch_update.id)
|
||||
.get_branch(branch_update.id)
|
||||
.map_err(|error| match error {
|
||||
reader::Error::NotFound => {
|
||||
errors::UpdateBranchError::BranchNotFound(errors::BranchNotFound {
|
||||
@ -1449,7 +1449,7 @@ pub fn update_branch(
|
||||
|
||||
pub fn delete_branch(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<(), Error> {
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
let branch = match vb_state.get_branch(branch_id) {
|
||||
@ -1986,7 +1986,7 @@ fn virtual_hunks_into_virtual_files(
|
||||
// reset virtual branch to a specific commit
|
||||
pub fn reset_branch(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: git::Oid,
|
||||
) -> Result<(), errors::ResetBranchError> {
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
@ -1997,7 +1997,7 @@ pub fn reset_branch(
|
||||
Ok(branch) => Ok(branch),
|
||||
Err(reader::Error::NotFound) => Err(errors::ResetBranchError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
project_id: project_repository.project().id,
|
||||
},
|
||||
)),
|
||||
@ -2262,7 +2262,7 @@ fn _print_tree(repo: &git2::Repository, tree: &git2::Tree) -> Result<()> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn commit(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
message: &str,
|
||||
ownership: Option<&branch::BranchOwnershipClaims>,
|
||||
user: Option<&users::User>,
|
||||
@ -2301,11 +2301,11 @@ pub fn commit(
|
||||
|
||||
let (ref mut branch, files) = statuses
|
||||
.into_iter()
|
||||
.find(|(branch, _)| branch.id == *branch_id)
|
||||
.find(|(branch, _)| branch.id == branch_id)
|
||||
.ok_or_else(|| {
|
||||
errors::CommitError::BranchNotFound(errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
})
|
||||
})?;
|
||||
|
||||
@ -2397,7 +2397,7 @@ pub fn commit(
|
||||
|
||||
pub fn push(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
with_force: bool,
|
||||
credentials: &git::credentials::Helper,
|
||||
askpass: Option<Option<BranchId>>,
|
||||
@ -2409,7 +2409,7 @@ pub fn push(
|
||||
.map_err(|error| match error {
|
||||
reader::Error::NotFound => errors::PushError::BranchNotFound(errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
}),
|
||||
error => errors::PushError::Other(error.into()),
|
||||
})?;
|
||||
@ -2589,7 +2589,7 @@ pub fn is_remote_branch_mergeable(
|
||||
|
||||
pub fn is_virtual_branch_mergeable(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
) -> Result<bool, errors::IsVirtualBranchMergeable> {
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
let branch = match vb_state.get_branch(branch_id) {
|
||||
@ -2597,7 +2597,7 @@ pub fn is_virtual_branch_mergeable(
|
||||
Err(reader::Error::NotFound) => Err(errors::IsVirtualBranchMergeable::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
},
|
||||
)),
|
||||
Err(error) => Err(errors::IsVirtualBranchMergeable::Other(error.into())),
|
||||
@ -2660,7 +2660,7 @@ pub fn is_virtual_branch_mergeable(
|
||||
// then added to the "to" commit and everything above that rebased again.
|
||||
pub fn move_commit_file(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
from_commit_oid: git::Oid,
|
||||
to_commit_oid: git::Oid,
|
||||
target_ownership: &BranchOwnershipClaims,
|
||||
@ -2920,7 +2920,7 @@ pub fn move_commit_file(
|
||||
// and the respective branch head is updated
|
||||
pub fn amend(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
target_ownership: &BranchOwnershipClaims,
|
||||
) -> Result<git::Oid, errors::VirtualBranchError> {
|
||||
@ -2938,11 +2938,11 @@ pub fn amend(
|
||||
.list_branches()
|
||||
.context("failed to read virtual branches")?;
|
||||
|
||||
if !all_branches.iter().any(|b| b.id == *branch_id) {
|
||||
if !all_branches.iter().any(|b| b.id == branch_id) {
|
||||
return Err(errors::VirtualBranchError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -2952,11 +2952,11 @@ pub fn amend(
|
||||
.filter(|b| b.applied)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !applied_branches.iter().any(|b| b.id == *branch_id) {
|
||||
if !applied_branches.iter().any(|b| b.id == branch_id) {
|
||||
return Err(errors::VirtualBranchError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -2975,11 +2975,11 @@ pub fn amend(
|
||||
|
||||
let (ref mut target_branch, target_status) = applied_statuses
|
||||
.iter_mut()
|
||||
.find(|(b, _)| b.id == *branch_id)
|
||||
.find(|(b, _)| b.id == branch_id)
|
||||
.ok_or_else(|| {
|
||||
errors::VirtualBranchError::BranchNotFound(errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
})
|
||||
})?;
|
||||
|
||||
@ -3103,7 +3103,7 @@ pub fn amend(
|
||||
// rewrites the branch head to the new head commit
|
||||
pub fn reorder_commit(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
offset: i32,
|
||||
) -> Result<(), errors::VirtualBranchError> {
|
||||
@ -3115,7 +3115,7 @@ pub fn reorder_commit(
|
||||
Ok(branch) => Ok(branch),
|
||||
Err(reader::Error::NotFound) => Err(errors::VirtualBranchError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
project_id: project_repository.project().id,
|
||||
},
|
||||
)),
|
||||
@ -3203,7 +3203,7 @@ pub fn reorder_commit(
|
||||
// return the oid of the new head commit of the branch with the inserted blank commit
|
||||
pub fn insert_blank_commit(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
user: Option<&users::User>,
|
||||
offset: i32,
|
||||
@ -3214,7 +3214,7 @@ pub fn insert_blank_commit(
|
||||
Ok(branch) => Ok(branch),
|
||||
Err(reader::Error::NotFound) => Err(errors::VirtualBranchError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
project_id: project_repository.project().id,
|
||||
},
|
||||
)),
|
||||
@ -3272,7 +3272,7 @@ pub fn insert_blank_commit(
|
||||
// if successful, it will update the branch head to the new head commit
|
||||
pub fn undo_commit(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), errors::VirtualBranchError> {
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
@ -3281,7 +3281,7 @@ pub fn undo_commit(
|
||||
Ok(branch) => Ok(branch),
|
||||
Err(reader::Error::NotFound) => Err(errors::VirtualBranchError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
project_id: project_repository.project().id,
|
||||
},
|
||||
)),
|
||||
@ -3428,7 +3428,7 @@ fn cherry_rebase_group(
|
||||
|
||||
pub fn cherry_pick(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
target_commit_oid: git::Oid,
|
||||
) -> Result<Option<git::Oid>, errors::CherryPickError> {
|
||||
if conflicts::is_conflicting::<&Path>(project_repository, None)? {
|
||||
@ -3483,7 +3483,7 @@ pub fn cherry_pick(
|
||||
|
||||
let branch_files = applied_statuses
|
||||
.iter()
|
||||
.find(|(b, _)| b.id == *branch_id)
|
||||
.find(|(b, _)| b.id == branch_id)
|
||||
.map(|(_, f)| f)
|
||||
.context("branch status not found")?;
|
||||
|
||||
@ -3526,7 +3526,7 @@ pub fn cherry_pick(
|
||||
.filter(|(b, _)| b.id != branch.id)
|
||||
.map(|(b, _)| b)
|
||||
{
|
||||
unapply_branch(project_repository, &other_branch.id).context("failed to unapply branch")?;
|
||||
unapply_branch(project_repository, other_branch.id).context("failed to unapply branch")?;
|
||||
}
|
||||
|
||||
let commit_oid = if cherrypick_index.has_conflicts() {
|
||||
@ -3611,7 +3611,7 @@ pub fn cherry_pick(
|
||||
/// squashes a commit from a virtual branch into it's parent.
|
||||
pub fn squash(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
) -> Result<(), errors::SquashError> {
|
||||
if conflicts::is_conflicting::<&Path>(project_repository, None)? {
|
||||
@ -3630,7 +3630,7 @@ pub fn squash(
|
||||
reader::Error::NotFound => {
|
||||
errors::SquashError::BranchNotFound(errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
})
|
||||
}
|
||||
error => errors::SquashError::Other(error.into()),
|
||||
@ -3735,7 +3735,7 @@ pub fn squash(
|
||||
// changes a commit message for commit_oid, rebases everything above it, updates branch head if successful
|
||||
pub fn update_commit_message(
|
||||
project_repository: &project_repository::Repository,
|
||||
branch_id: &BranchId,
|
||||
branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
message: &str,
|
||||
) -> Result<(), errors::UpdateCommitMessageError> {
|
||||
@ -3760,7 +3760,7 @@ pub fn update_commit_message(
|
||||
reader::Error::NotFound => {
|
||||
errors::UpdateCommitMessageError::BranchNotFound(errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *branch_id,
|
||||
branch_id,
|
||||
})
|
||||
}
|
||||
error => errors::UpdateCommitMessageError::Other(error.into()),
|
||||
@ -3849,7 +3849,7 @@ pub fn update_commit_message(
|
||||
/// moves commit from the branch it's in to the top of the target branch
|
||||
pub fn move_commit(
|
||||
project_repository: &project_repository::Repository,
|
||||
target_branch_id: &BranchId,
|
||||
target_branch_id: BranchId,
|
||||
commit_oid: git::Oid,
|
||||
user: Option<&users::User>,
|
||||
) -> Result<(), errors::MoveCommitError> {
|
||||
@ -3870,11 +3870,11 @@ pub fn move_commit(
|
||||
.filter(|b| b.applied)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !applied_branches.iter().any(|b| b.id == *target_branch_id) {
|
||||
if !applied_branches.iter().any(|b| b.id == target_branch_id) {
|
||||
return Err(errors::MoveCommitError::BranchNotFound(
|
||||
errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *target_branch_id,
|
||||
branch_id: target_branch_id,
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -3968,7 +3968,7 @@ pub fn move_commit(
|
||||
reader::Error::NotFound => {
|
||||
errors::MoveCommitError::BranchNotFound(errors::BranchNotFound {
|
||||
project_id: project_repository.project().id,
|
||||
branch_id: *target_branch_id,
|
||||
branch_id: target_branch_id,
|
||||
})
|
||||
}
|
||||
error => errors::MoveCommitError::Other(error.into()),
|
||||
@ -4148,7 +4148,7 @@ pub fn create_virtual_branch_from_branch(
|
||||
|
||||
project_repository.add_branch_reference(&branch)?;
|
||||
|
||||
match apply_branch(project_repository, &branch.id, user) {
|
||||
match apply_branch(project_repository, branch.id, user) {
|
||||
Ok(()) => Ok(branch.id),
|
||||
Err(errors::ApplyBranchError::BranchConflicts(_)) => {
|
||||
// if branch conflicts with the workspace, it's ok. keep it unapplied
|
||||
|
@ -28,12 +28,12 @@ impl Controller {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn archive(&self, project_id: &ProjectId) -> Result<path::PathBuf, Error> {
|
||||
pub fn archive(&self, project_id: ProjectId) -> Result<path::PathBuf, Error> {
|
||||
let project = self.projects_controller.get(project_id)?;
|
||||
self.zipper.zip(project.path).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn data_archive(&self, project_id: &ProjectId) -> Result<path::PathBuf, Error> {
|
||||
pub fn data_archive(&self, project_id: ProjectId) -> Result<path::PathBuf, Error> {
|
||||
let project = self.projects_controller.get(project_id)?;
|
||||
self.zipper
|
||||
.zip(
|
||||
|
@ -123,9 +123,9 @@ mod delete {
|
||||
let repository = gitbutler_testsupport::TestProject::default();
|
||||
let path = repository.path();
|
||||
let project = controller.add(path).unwrap();
|
||||
assert!(controller.delete(&project.id).await.is_ok());
|
||||
assert!(controller.delete(&project.id).await.is_ok()); // idempotent
|
||||
assert!(controller.get(&project.id).is_err());
|
||||
assert!(controller.delete(project.id).await.is_ok());
|
||||
assert!(controller.delete(project.id).await.is_ok()); // idempotent
|
||||
assert!(controller.get(project.id).is_err());
|
||||
assert!(!project.gb_dir().exists());
|
||||
assert!(!project.path.join(".gitbutler.json").exists());
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -34,19 +34,19 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -55,12 +55,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_id, branch_id, commit_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -85,7 +85,7 @@ async fn forcepush_forbidden() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -99,19 +99,19 @@ async fn forcepush_forbidden() {
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -120,7 +120,7 @@ async fn forcepush_forbidden() {
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
assert!(matches!(
|
||||
controller
|
||||
.amend(project_id, &branch_id, commit_oid, &to_amend)
|
||||
.amend(*project_id, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -139,24 +139,24 @@ async fn non_locked_hunk() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -172,12 +172,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_id, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -200,24 +200,24 @@ async fn locked_hunk() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -237,12 +237,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_id, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -270,24 +270,24 @@ async fn non_existing_ownership() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -303,7 +303,7 @@ async fn non_existing_ownership() {
|
||||
let to_amend: branch::BranchOwnershipClaims = "file2.txt:1-2".parse().unwrap();
|
||||
assert!(matches!(
|
||||
controller
|
||||
.amend(project_id, &branch_id, commit_oid, &to_amend)
|
||||
.amend(*project_id, branch_id, commit_oid, &to_amend)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
|
@ -10,13 +10,13 @@ async fn deltect_conflict() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = {
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("file.txt"), "branch one").unwrap();
|
||||
@ -26,14 +26,14 @@ async fn deltect_conflict() {
|
||||
|
||||
// unapply first vbranch
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branch1_id)
|
||||
.unapply_virtual_branch(*project_id, branch1_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
// create another vbranch that conflicts with the first one
|
||||
controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
fs::write(repository.path().join("file.txt"), "branch two").unwrap();
|
||||
@ -42,13 +42,13 @@ async fn deltect_conflict() {
|
||||
{
|
||||
// it should not be possible to apply the first branch
|
||||
assert!(!controller
|
||||
.can_apply_virtual_branch(project_id, &branch1_id)
|
||||
.can_apply_virtual_branch(*project_id, branch1_id)
|
||||
.await
|
||||
.unwrap());
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.apply_virtual_branch(project_id, &branch1_id)
|
||||
.apply_virtual_branch(*project_id, branch1_id)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -78,24 +78,24 @@ async fn rebase_commit() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let 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_id, &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_id, 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
@ -108,7 +108,7 @@ async fn rebase_commit() {
|
||||
{
|
||||
// unapply first vbranch
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branch1_id)
|
||||
.unapply_virtual_branch(*project_id, branch1_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -121,7 +121,7 @@ async fn rebase_commit() {
|
||||
"one"
|
||||
);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 0);
|
||||
@ -131,10 +131,10 @@ async fn rebase_commit() {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(project_id).await.unwrap();
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
|
||||
// branch is stil unapplied
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 0);
|
||||
@ -155,12 +155,12 @@ async fn rebase_commit() {
|
||||
{
|
||||
// apply first vbranch again
|
||||
controller
|
||||
.apply_virtual_branch(project_id, &branch1_id)
|
||||
.apply_virtual_branch(*project_id, branch1_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// it should be rebased
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 0);
|
||||
@ -199,19 +199,19 @@ async fn rebase_work() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = {
|
||||
// make a branch with some work
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
@ -224,11 +224,11 @@ async fn rebase_work() {
|
||||
{
|
||||
// unapply first vbranch
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branch1_id)
|
||||
.unapply_virtual_branch(*project_id, branch1_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
@ -241,10 +241,10 @@ async fn rebase_work() {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(project_id).await.unwrap();
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
|
||||
// first branch is stil unapplied
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
@ -259,12 +259,12 @@ async fn rebase_work() {
|
||||
{
|
||||
// apply first vbranch again
|
||||
controller
|
||||
.apply_virtual_branch(project_id, &branch1_id)
|
||||
.apply_virtual_branch(*project_id, branch1_id)
|
||||
.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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
|
@ -14,19 +14,19 @@ mod cleanly {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one = {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -34,18 +34,18 @@ mod cleanly {
|
||||
let commit_two = {
|
||||
fs::write(repository.path().join("file.txt"), "content two").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reset_virtual_branch(project_id, &branch_id, commit_one)
|
||||
.reset_virtual_branch(*project_id, branch_id, commit_one)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -57,7 +57,7 @@ mod cleanly {
|
||||
);
|
||||
|
||||
let cherry_picked_commit_oid = controller
|
||||
.cherry_pick(project_id, &branch_id, commit_two)
|
||||
.cherry_pick(*project_id, branch_id, commit_two)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(cherry_picked_commit_oid.is_some());
|
||||
@ -67,7 +67,7 @@ mod cleanly {
|
||||
"content two"
|
||||
);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -86,19 +86,19 @@ mod cleanly {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one = {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -106,18 +106,18 @@ mod cleanly {
|
||||
let commit_two = {
|
||||
fs::write(repository.path().join("file_two.txt"), "content two").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reset_virtual_branch(project_id, &branch_id, commit_one)
|
||||
.reset_virtual_branch(*project_id, branch_id, commit_one)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -130,17 +130,17 @@ mod cleanly {
|
||||
assert!(!repository.path().join("file_two.txt").exists());
|
||||
|
||||
let branch_two_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let cherry_picked_commit_oid = controller
|
||||
.cherry_pick(project_id, &branch_two_id, commit_two)
|
||||
.cherry_pick(*project_id, branch_two_id, commit_two)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(cherry_picked_commit_oid.is_some());
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert!(repository.path().join("file_two.txt").exists());
|
||||
assert_eq!(
|
||||
fs::read_to_string(repository.path().join("file_two.txt")).unwrap(),
|
||||
@ -169,19 +169,19 @@ mod cleanly {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one_oid = {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -189,7 +189,7 @@ mod cleanly {
|
||||
{
|
||||
fs::write(repository.path().join("file_two.txt"), "content two").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -197,24 +197,24 @@ mod cleanly {
|
||||
let commit_three_oid = {
|
||||
fs::write(repository.path().join("file_three.txt"), "content three").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.reset_virtual_branch(project_id, &branch_id, commit_one_oid)
|
||||
.reset_virtual_branch(*project_id, branch_id, commit_one_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branch_id)
|
||||
.unapply_virtual_branch(*project_id, branch_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.cherry_pick(project_id, &branch_id, commit_three_oid)
|
||||
.cherry_pick(*project_id, branch_id, commit_three_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -237,19 +237,19 @@ mod with_conflicts {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit_one = {
|
||||
fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit one", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -257,7 +257,7 @@ mod with_conflicts {
|
||||
{
|
||||
fs::write(repository.path().join("file_two.txt"), "content two").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit two", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -265,18 +265,18 @@ mod with_conflicts {
|
||||
let commit_three = {
|
||||
fs::write(repository.path().join("file_three.txt"), "content three").unwrap();
|
||||
controller
|
||||
.create_commit(project_id, &branch_id, "commit three", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reset_virtual_branch(project_id, &branch_id, commit_one)
|
||||
.reset_virtual_branch(*project_id, branch_id, commit_one)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -294,7 +294,7 @@ mod with_conflicts {
|
||||
{
|
||||
// cherry picking leads to conflict
|
||||
let cherry_picked_commit_oid = controller
|
||||
.cherry_pick(project_id, &branch_id, commit_three)
|
||||
.cherry_pick(*project_id, branch_id, commit_three)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(cherry_picked_commit_oid.is_none());
|
||||
@ -304,7 +304,7 @@ mod with_conflicts {
|
||||
"<<<<<<< ours\nconflict\n=======\ncontent three\n>>>>>>> theirs\n"
|
||||
);
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -318,14 +318,14 @@ mod with_conflicts {
|
||||
// conflict can be resolved
|
||||
fs::write(repository.path().join("file_three.txt"), "resolved").unwrap();
|
||||
let commited_oid = controller
|
||||
.create_commit(project_id, &branch_id, "resolution", None, false)
|
||||
.create_commit(*project_id, branch_id, "resolution", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let commit = repository.find_commit(commited_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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -357,12 +357,12 @@ mod with_conflicts {
|
||||
};
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -370,13 +370,13 @@ mod with_conflicts {
|
||||
fs::write(repository.path().join("file.txt"), "conflict").unwrap();
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branch_id)
|
||||
.unapply_virtual_branch(*project_id, branch_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.cherry_pick(project_id, &branch_id, commit_oid)
|
||||
.cherry_pick(*project_id, branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
|
@ -15,12 +15,12 @@ async fn should_lock_updated_hunks() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -28,7 +28,7 @@ async fn should_lock_updated_hunks() {
|
||||
// by default, hunks are not locked
|
||||
write_file(repository, "file.txt", &["content".to_string()]);
|
||||
|
||||
let branch = get_virtual_branch(controller, project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, *project_id, 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_id, branch_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -45,7 +45,7 @@ async fn should_lock_updated_hunks() {
|
||||
write_file(repository, "file.txt", &["updated content".to_string()]);
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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();
|
||||
write_file(repository, "file.txt", &lines);
|
||||
let branch = get_virtual_branch(controller, project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, *project_id, 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_id, branch_id, "test commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, 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();
|
||||
write_file(repository, "file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, *project_id, 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();
|
||||
write_file(repository, "file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, *project_id, 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();
|
||||
write_file(repository, "file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, *project_id, 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();
|
||||
write_file(repository, "file.txt", &changed_lines);
|
||||
let branch = get_virtual_branch(controller, project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, *project_id, 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);
|
||||
@ -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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_2_id = controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -196,11 +196,11 @@ async fn should_reset_into_same_branch() {
|
||||
write_file(repository, "file.txt", &lines);
|
||||
|
||||
controller
|
||||
.create_commit(project_id, &branch_2_id, "commit to branch 2", None, false)
|
||||
.create_commit(*project_id, 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_id, 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_id,
|
||||
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_id, 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_id, branch_2_id)
|
||||
.await
|
||||
.files;
|
||||
assert_eq!(files.len(), 1);
|
||||
@ -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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -256,7 +256,7 @@ async fn should_double_lock() {
|
||||
write_file(repository, "file.txt", &lines);
|
||||
|
||||
let commit_1 = controller
|
||||
.create_commit(project_id, &branch_id, "commit 1", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit 1", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -264,14 +264,14 @@ async fn should_double_lock() {
|
||||
write_file(repository, "file.txt", &lines);
|
||||
|
||||
let commit_2 = controller
|
||||
.create_commit(project_id, &branch_id, "commit 2", None, false)
|
||||
.create_commit(*project_id, branch_id, "commit 2", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
lines[3] = "change3".to_string();
|
||||
write_file(repository, "file.txt", &lines);
|
||||
|
||||
let branch = get_virtual_branch(controller, project_id, branch_id).await;
|
||||
let branch = get_virtual_branch(controller, *project_id, branch_id).await;
|
||||
let locks = &branch.files[0].hunks[0].locked_to.clone().unwrap();
|
||||
|
||||
assert_eq!(locks.len(), 2);
|
||||
@ -296,7 +296,7 @@ fn commit_and_push_initial(repository: &TestProject) {
|
||||
|
||||
async fn get_virtual_branch(
|
||||
controller: &Controller,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
branch_id: Id<Branch>,
|
||||
) -> VirtualBranch {
|
||||
controller
|
||||
|
@ -10,7 +10,7 @@ async fn integration() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id, &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_id, branch_id, "first", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.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_id, 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_id, &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_id, 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_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -103,12 +103,12 @@ async fn integration() {
|
||||
{
|
||||
// should mark commits as integrated
|
||||
controller
|
||||
.fetch_from_remotes(project_id, None)
|
||||
.fetch_from_remotes(*project_id, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -143,22 +143,22 @@ async fn no_conflicts() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).await.unwrap();
|
||||
assert!(branches.is_empty());
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -185,7 +185,7 @@ async fn conflicts_with_uncommited() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -193,7 +193,7 @@ 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
};
|
||||
|
||||
@ -201,13 +201,13 @@ async fn conflicts_with_uncommited() {
|
||||
|
||||
let new_branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let new_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -239,7 +239,7 @@ async fn conflicts_with_commited() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -247,11 +247,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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
controller
|
||||
.create_commit(project_id, &branches[0].id, "hej", None, false)
|
||||
.create_commit(*project_id, branches[0].id, "hej", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
};
|
||||
@ -260,13 +260,13 @@ async fn conflicts_with_commited() {
|
||||
|
||||
let new_branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let new_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -287,7 +287,7 @@ async fn from_default_target() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -296,7 +296,7 @@ async fn from_default_target() {
|
||||
assert!(matches!(
|
||||
controller
|
||||
.create_virtual_branch_from_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&"refs/remotes/origin/master".parse().unwrap(),
|
||||
)
|
||||
.await
|
||||
@ -315,7 +315,7 @@ async fn from_non_existent_branch() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -324,7 +324,7 @@ async fn from_non_existent_branch() {
|
||||
assert!(matches!(
|
||||
controller
|
||||
.create_virtual_branch_from_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&"refs/remotes/origin/branch".parse().unwrap(),
|
||||
)
|
||||
.await
|
||||
@ -361,19 +361,19 @@ async fn from_state_remote_branch() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch_from_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
|
@ -10,21 +10,21 @@ async fn should_unapply_diff() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).await.unwrap();
|
||||
|
||||
controller
|
||||
.delete_virtual_branch(project_id, &branches[0].id)
|
||||
.delete_virtual_branch(*project_id, branches[0].id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert!(!repository.path().join("file.txt").exists());
|
||||
|
||||
@ -46,13 +46,13 @@ async fn should_remove_reference() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let id = controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -62,11 +62,11 @@ async fn should_remove_reference() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.delete_virtual_branch(project_id, &id)
|
||||
.delete_virtual_branch(*project_id, id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
let refnames = repository
|
||||
|
@ -9,31 +9,31 @@ async fn should_update_last_fetched() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).await.unwrap();
|
||||
assert!(before_fetch.last_fetched_ms.is_none());
|
||||
|
||||
let fetch = controller
|
||||
.fetch_from_remotes(project_id, None)
|
||||
.fetch_from_remotes(*project_id, None)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(fetch.last_fetched_ms.is_some());
|
||||
|
||||
let after_fetch = controller.get_base_branch_data(project_id).await.unwrap();
|
||||
let after_fetch = controller.get_base_branch_data(*project_id).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)
|
||||
.fetch_from_remotes(*project_id, 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 after_second_fetch = controller.get_base_branch_data(*project_id).await.unwrap();
|
||||
assert!(after_second_fetch.last_fetched_ms.is_some());
|
||||
assert_eq!(
|
||||
second_fetch.last_fetched_ms,
|
||||
|
@ -16,18 +16,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.id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(controller
|
||||
.list_virtual_branches(&project.id)
|
||||
.list_virtual_branches(project.id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
.is_empty());
|
||||
projects.delete(&project.id).await.unwrap();
|
||||
projects.delete(project.id).await.unwrap();
|
||||
controller
|
||||
.list_virtual_branches(&project.id)
|
||||
.list_virtual_branches(project.id)
|
||||
.await
|
||||
.unwrap_err();
|
||||
}
|
||||
@ -35,13 +35,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.id, &"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.id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -65,11 +65,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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks.len(), 1);
|
||||
@ -91,11 +91,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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks.len(), 1);
|
||||
@ -117,11 +117,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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].files.is_empty());
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -144,11 +144,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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].files.is_empty());
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -169,11 +169,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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].files.is_empty());
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -195,11 +195,11 @@ async fn submodule() {
|
||||
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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks.len(), 1);
|
||||
|
@ -10,19 +10,19 @@ async fn insert_blank_commit_down() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, 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_id, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.insert_blank_commit(project_id, &branch_id, commit2_id, 1)
|
||||
.insert_blank_commit(*project_id, branch_id, commit2_id, 1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -82,19 +82,19 @@ async fn insert_blank_commit_up() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, 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_id, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.insert_blank_commit(project_id, &branch_id, commit2_id, -1)
|
||||
.insert_blank_commit(*project_id, branch_id, commit2_id, -1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -96,19 +96,19 @@ async fn resolve_conflict_flow() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = {
|
||||
// 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_id, &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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
@ -118,10 +118,10 @@ async fn resolve_conflict_flow() {
|
||||
|
||||
{
|
||||
// fetch remote
|
||||
controller.update_base_branch(project_id).await.unwrap();
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
|
||||
// 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(!branches[0].active);
|
||||
@ -130,11 +130,11 @@ async fn resolve_conflict_flow() {
|
||||
{
|
||||
// when we apply conflicted branch, it has conflict
|
||||
controller
|
||||
.apply_virtual_branch(project_id, &branch1_id)
|
||||
.apply_virtual_branch(*project_id, branch1_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
@ -151,7 +151,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_id, branch1_id, "commit conflicts", None, false)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -163,14 +163,14 @@ async fn resolve_conflict_flow() {
|
||||
// fixing the conflict removes conflicted mark
|
||||
fs::write(repository.path().join("file.txt"), "resolved").unwrap();
|
||||
let commit_oid = controller
|
||||
.create_commit(project_id, &branch1_id, "resolution", None, false)
|
||||
.create_commit(*project_id, 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert!(branches[0].active);
|
||||
|
@ -10,19 +10,19 @@ async fn move_file_down() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
let commit1 = repository.find_commit(commit1_id).unwrap();
|
||||
@ -31,7 +31,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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
let commit2 = repository.find_commit(commit2_id).unwrap();
|
||||
@ -39,12 +39,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_id, branch_id, commit2_id, commit1_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -74,12 +74,12 @@ async fn move_file_up() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -87,26 +87,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_id, 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_id, 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_id, branch_id, commit1_id, commit2_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -133,19 +133,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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -153,7 +153,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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -165,26 +165,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_id, 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_id, 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_id, branch_id, commit2_id, commit3_id, &to_amend)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -17,34 +17,34 @@ async fn no_diffs() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).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_id, 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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.move_commit(project_id, &target_branch_id, commit_oid)
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let destination_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -53,7 +53,7 @@ async fn no_diffs() {
|
||||
.unwrap();
|
||||
|
||||
let source_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -77,19 +77,19 @@ async fn diffs_on_source_branch() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).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_id, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -100,17 +100,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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.move_commit(project_id, &target_branch_id, commit_oid)
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let destination_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -119,7 +119,7 @@ async fn diffs_on_source_branch() {
|
||||
.unwrap();
|
||||
|
||||
let source_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -143,25 +143,25 @@ async fn diffs_on_target_branch() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).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_id, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let target_branch_id = controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -177,12 +177,12 @@ async fn diffs_on_target_branch() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.move_commit(project_id, &target_branch_id, commit_oid)
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let destination_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -191,7 +191,7 @@ async fn diffs_on_target_branch() {
|
||||
.unwrap();
|
||||
|
||||
let source_branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -215,32 +215,32 @@ async fn locked_hunks_on_source_branch() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).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_id, 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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.move_commit(project_id, &target_branch_id, commit_oid)
|
||||
.move_commit(*project_id, target_branch_id, commit_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -258,32 +258,32 @@ async fn no_commit() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).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_id, 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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.move_commit(
|
||||
project_id,
|
||||
&target_branch_id,
|
||||
*project_id,
|
||||
target_branch_id,
|
||||
git::Oid::from_str("a99c95cca7a60f1a2180c2f86fb18af97333c192").unwrap()
|
||||
)
|
||||
.await
|
||||
@ -303,25 +303,25 @@ async fn no_branch() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).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_id, source_branch_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.move_commit(project_id, &BranchId::generate(), commit_oid)
|
||||
.move_commit(*project_id, BranchId::generate(), commit_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
|
@ -14,7 +14,7 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -22,7 +22,7 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
|
||||
let workdir = repository.path();
|
||||
for round in 0..3 {
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await?;
|
||||
branch_ids.push(branch_id);
|
||||
fs::write(
|
||||
@ -31,8 +31,8 @@ async fn workdir_vbranch_restore() -> anyhow::Result<()> {
|
||||
)?;
|
||||
controller
|
||||
.create_commit(
|
||||
project_id,
|
||||
&branch_id,
|
||||
*project_id,
|
||||
branch_id,
|
||||
"first commit",
|
||||
None,
|
||||
false, /* run hook */
|
||||
@ -67,17 +67,17 @@ async fn basic_oplog() -> anyhow::Result<()> {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse()?)
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse()?)
|
||||
.await?;
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await?;
|
||||
|
||||
// dont store large files
|
||||
@ -93,7 +93,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_id, branch_id, "commit two", None, false)
|
||||
.await?;
|
||||
|
||||
// Create conflict state
|
||||
@ -104,7 +104,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_id, &branch::BranchCreateRequest::default())
|
||||
.await?;
|
||||
|
||||
std::fs::remove_file(&base_merge_parent_path)?;
|
||||
@ -112,18 +112,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_id, branch_id, "commit three", None, false)
|
||||
.await?;
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.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_id).await?;
|
||||
assert_eq!(branches.0.len(), 2);
|
||||
|
||||
assert_eq!(branch.commits.len(), 3);
|
||||
@ -162,7 +162,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_id).await?;
|
||||
assert_eq!(branches.0.len(), 1);
|
||||
|
||||
// assert that the conflicts file was removed
|
||||
@ -217,19 +217,19 @@ async fn restores_gitbutler_integration() -> anyhow::Result<()> {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse()?)
|
||||
.set_base_branch(*project_id, &"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_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await?;
|
||||
|
||||
let repo = git2::Repository::open(&project.path)?;
|
||||
@ -244,7 +244,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_id, branch_id, "commit two", None, false)
|
||||
.await?;
|
||||
|
||||
// check the integration commit changed
|
||||
@ -330,11 +330,11 @@ async fn head_corrupt_is_recreated_automatically() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -354,7 +354,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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.expect("the snapshot doesn't fail despite the corrupt head");
|
||||
|
||||
|
@ -13,16 +13,16 @@ mod create_virtual_branch {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].name, "Virtual branch");
|
||||
@ -45,13 +45,13 @@ mod create_virtual_branch {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&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_id,
|
||||
&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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 2);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].name, "name");
|
||||
@ -101,13 +101,13 @@ mod update_virtual_branch {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&branch::BranchCreateRequest {
|
||||
name: Some("name".to_string()),
|
||||
..Default::default()
|
||||
@ -118,7 +118,7 @@ mod update_virtual_branch {
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch_id);
|
||||
assert_eq!(branches[0].name, "new name");
|
||||
@ -152,13 +152,13 @@ mod update_virtual_branch {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&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_id,
|
||||
&branch::BranchCreateRequest {
|
||||
..Default::default()
|
||||
},
|
||||
@ -179,7 +179,7 @@ mod update_virtual_branch {
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 2);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].name, "name");
|
||||
@ -220,13 +220,13 @@ mod push_virtual_branch {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&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_id, branch1_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch1_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch1_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].name, "name");
|
||||
@ -273,7 +273,7 @@ mod push_virtual_branch {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id,
|
||||
&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_id, branch1_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch1_id, false, None)
|
||||
.push_virtual_branch(*project_id, 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_id,
|
||||
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_id,
|
||||
&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_id, branch2_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch2_id, false, None)
|
||||
.push_virtual_branch(*project_id, 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 2);
|
||||
// first branch is pushing to old ref remotely
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
|
@ -10,19 +10,19 @@ async fn reorder_commit_down() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reorder_commit(project_id, &branch_id, commit2_id, 1)
|
||||
.reorder_commit(*project_id, branch_id, commit2_id, 1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -71,19 +71,19 @@ async fn reorder_commit_up() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.reorder_commit(project_id, &branch_id, commit1_id, -1)
|
||||
.reorder_commit(*project_id, branch_id, commit1_id, -1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -14,12 +14,12 @@ async fn to_head() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).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_id, branch1_id, oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -76,12 +76,12 @@ async fn to_target() {
|
||||
} = &Test::default();
|
||||
|
||||
let base_branch = controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).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_id, 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 0);
|
||||
@ -135,12 +135,12 @@ async fn to_commit() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).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_id, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).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_id, branch1_id, first_commit_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -220,12 +220,12 @@ async fn to_non_existing() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 1);
|
||||
@ -255,8 +255,8 @@ async fn to_non_existing() {
|
||||
assert!(matches!(
|
||||
controller
|
||||
.reset_virtual_branch(
|
||||
project_id,
|
||||
&branch1_id,
|
||||
*project_id,
|
||||
branch1_id,
|
||||
"fe14df8c66b73c6276f7bb26102ad91da680afcb".parse().unwrap()
|
||||
)
|
||||
.await
|
||||
|
@ -10,7 +10,7 @@ async fn unapplying_selected_branch_selects_anther() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id, &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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).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
|
||||
.unapply_virtual_branch(project_id, &b_id)
|
||||
.unapply_virtual_branch(*project_id, b_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
|
||||
assert_eq!(branches.len(), 2);
|
||||
assert_eq!(branches[0].id, b.id);
|
||||
@ -62,23 +62,23 @@ async fn deleting_selected_branch_selects_anther() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id, &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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
|
||||
let b = branches.iter().find(|b| b.id == b_id).unwrap();
|
||||
|
||||
@ -88,11 +88,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_id, b_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, b2.id);
|
||||
@ -108,17 +108,17 @@ async fn create_virtual_branch_should_set_selected_for_changes() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -129,11 +129,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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -145,7 +145,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_id,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(false),
|
||||
..Default::default()
|
||||
@ -154,7 +154,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_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -166,7 +166,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_id,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -175,7 +175,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_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -194,16 +194,16 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let b1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let b1 = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -213,11 +213,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_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let b2 = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -228,7 +228,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
|
||||
controller
|
||||
.update_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
branch::BranchUpdateRequest {
|
||||
id: b2_id,
|
||||
selected_for_changes: Some(true),
|
||||
@ -239,7 +239,7 @@ async fn update_virtual_branch_should_reset_selected_for_changes() {
|
||||
.unwrap();
|
||||
|
||||
let b1 = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -249,7 +249,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_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -269,18 +269,18 @@ async fn unapply_virtual_branch_should_reset_selected_for_changes() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let b1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -290,12 +290,12 @@ async fn unapply_virtual_branch_should_reset_selected_for_changes() {
|
||||
assert!(b1.selected_for_changes);
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &b1_id)
|
||||
.unapply_virtual_branch(*project_id, b1_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let b1 = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -315,18 +315,18 @@ async fn hunks_distribution() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
|
||||
controller
|
||||
.create_virtual_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&branch::BranchCreateRequest {
|
||||
selected_for_changes: Some(true),
|
||||
..Default::default()
|
||||
@ -335,7 +335,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_id).await.unwrap();
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[1].files.len(), 1);
|
||||
}
|
||||
@ -350,25 +350,25 @@ async fn applying_first_branch() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branches[0].id)
|
||||
.unapply_virtual_branch(*project_id, branches[0].id)
|
||||
.await
|
||||
.unwrap();
|
||||
controller
|
||||
.apply_virtual_branch(project_id, &branches[0].id)
|
||||
.apply_virtual_branch(*project_id, branches[0].id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].active);
|
||||
assert!(branches[0].selected_for_changes);
|
||||
|
@ -9,7 +9,7 @@ async fn success() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
@ -28,7 +28,7 @@ mod error {
|
||||
assert!(matches!(
|
||||
controller
|
||||
.set_base_branch(
|
||||
project_id,
|
||||
*project_id,
|
||||
&git::RemoteRefname::from_str("refs/remotes/origin/missing").unwrap(),
|
||||
)
|
||||
.await
|
||||
@ -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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let vbranch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, vbranch_id, "one", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, vbranch_id);
|
||||
assert!(branches[0].active);
|
||||
@ -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_id, &"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_id).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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -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_id, &"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_id).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_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -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_id, &"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_id).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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert_eq!(base_two, base);
|
||||
}
|
||||
@ -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_id, &"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_id).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_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert_eq!(base_two, base);
|
||||
}
|
||||
|
@ -10,19 +10,19 @@ async fn head() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, 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_id, 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_id, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.squash(project_id, &branch_id, commit_four_oid)
|
||||
.squash(*project_id, branch_id, commit_four_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -86,19 +86,19 @@ async fn middle() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, 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_id, 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_id, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.squash(project_id, &branch_id, commit_two_oid)
|
||||
.squash(*project_id, branch_id, commit_two_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -172,32 +172,32 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, 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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -205,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_id, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -213,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_id, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.squash(project_id, &branch_id, commit_two_oid)
|
||||
.squash(*project_id, branch_id, commit_two_oid)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -255,25 +255,25 @@ async fn forcepush_forbidden() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -289,7 +289,7 @@ async fn forcepush_forbidden() {
|
||||
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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -297,7 +297,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_id, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -305,14 +305,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_id, branch_id, "commit four", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.squash(project_id, &branch_id, commit_two_oid)
|
||||
.squash(*project_id, branch_id, commit_two_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -330,26 +330,26 @@ async fn root() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.squash(project_id, &branch_id, commit_one_oid)
|
||||
.squash(*project_id, branch_id, commit_one_oid)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
|
@ -10,23 +10,23 @@ async fn unapply_with_data() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branches[0].id)
|
||||
.unapply_virtual_branch(*project_id, branches[0].id)
|
||||
.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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(!branches[0].active);
|
||||
}
|
||||
@ -51,7 +51,7 @@ async fn conflicting() {
|
||||
}
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -60,7 +60,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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].base_current);
|
||||
assert!(branches[0].active);
|
||||
@ -70,7 +70,7 @@ async fn conflicting() {
|
||||
);
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branches[0].id)
|
||||
.unapply_virtual_branch(*project_id, branches[0].id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -79,7 +79,7 @@ async fn conflicting() {
|
||||
|
||||
{
|
||||
// update base branch, causing conflict
|
||||
controller.update_base_branch(project_id).await.unwrap();
|
||||
controller.update_base_branch(*project_id).await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(repository.path().join("file.txt")).unwrap(),
|
||||
@ -87,7 +87,7 @@ async fn conflicting() {
|
||||
);
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -101,7 +101,7 @@ async fn conflicting() {
|
||||
{
|
||||
// apply branch, it should conflict
|
||||
controller
|
||||
.apply_virtual_branch(project_id, &branch_id)
|
||||
.apply_virtual_branch(*project_id, branch_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -111,7 +111,7 @@ async fn conflicting() {
|
||||
);
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -125,7 +125,7 @@ async fn conflicting() {
|
||||
|
||||
{
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branch_id)
|
||||
.unapply_virtual_branch(*project_id, branch_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -135,7 +135,7 @@ async fn conflicting() {
|
||||
);
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -161,23 +161,23 @@ async fn delete_if_empty() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &branch::BranchCreateRequest::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branches[0].id)
|
||||
.unapply_virtual_branch(*project_id, branches[0].id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (branches, _) = controller.list_virtual_branches(project_id).await.unwrap();
|
||||
let (branches, _) = controller.list_virtual_branches(*project_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ async fn should_unapply_with_commits() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "test", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -42,7 +42,7 @@ async fn should_unapply_with_commits() {
|
||||
|
||||
controller
|
||||
.unapply_ownership(
|
||||
project_id,
|
||||
*project_id,
|
||||
&"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_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
@ -10,19 +10,19 @@ async fn undo_commit_simple() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, 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_id, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.undo_commit(project_id, &branch_id, commit2_id)
|
||||
.undo_commit(*project_id, branch_id, commit2_id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,19 +10,19 @@ async fn head() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -38,7 +38,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_id, branch_id, "commit three", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -47,8 +47,8 @@ async fn head() {
|
||||
|
||||
controller
|
||||
.update_commit_message(
|
||||
project_id,
|
||||
&branch_id,
|
||||
*project_id,
|
||||
branch_id,
|
||||
commit_three_oid,
|
||||
"commit three updated",
|
||||
)
|
||||
@ -56,7 +56,7 @@ async fn head() {
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -93,19 +93,19 @@ async fn middle() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -113,7 +113,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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -121,18 +121,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_id, 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_id, branch_id, commit_two_oid, "commit two updated")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -162,7 +162,7 @@ async fn forcepush_allowed() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -176,30 +176,30 @@ async fn forcepush_allowed() {
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
controller
|
||||
.update_commit_message(project_id, &branch_id, commit_one_oid, "commit one updated")
|
||||
.update_commit_message(*project_id, branch_id, commit_one_oid, "commit one updated")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -227,7 +227,7 @@ async fn forcepush_forbidden() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -241,26 +241,26 @@ async fn forcepush_forbidden() {
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.update_commit_message(project_id, &branch_id, commit_one_oid, "commit one updated",)
|
||||
.update_commit_message(*project_id, branch_id, commit_one_oid, "commit one updated",)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
@ -278,19 +278,19 @@ async fn root() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -298,7 +298,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_id, branch_id, "commit two", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
@ -306,18 +306,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_id, 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_id, branch_id, commit_one_oid, "commit one updated")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.0
|
||||
@ -346,26 +346,26 @@ async fn empty() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, branch_id, "commit one", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
assert!(matches!(
|
||||
controller
|
||||
.update_commit_message(project_id, &branch_id, commit_one_oid, "",)
|
||||
.update_commit_message(*project_id, branch_id, commit_one_oid, "",)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.downcast_ref(),
|
||||
|
@ -10,12 +10,12 @@ async fn detect_upstream_commits() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
// push
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch1_id, false, None)
|
||||
.push_virtual_branch(*project_id, 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_id, 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 3);
|
||||
@ -77,12 +77,12 @@ async fn detect_integrated_commits() {
|
||||
} = &Test::default();
|
||||
|
||||
controller
|
||||
.set_base_branch(project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.set_base_branch(*project_id, &"refs/remotes/origin/master".parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let branch1_id = controller
|
||||
.create_virtual_branch(project_id, &branch::BranchCreateRequest::default())
|
||||
.create_virtual_branch(*project_id, &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_id, 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_id, branch1_id, "commit", None, false)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
// push
|
||||
controller
|
||||
.push_virtual_branch(project_id, &branch1_id, false, None)
|
||||
.push_virtual_branch(*project_id, branch1_id, false, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
// merge branch upstream
|
||||
let branch = controller
|
||||
.list_virtual_branches(project_id)
|
||||
.list_virtual_branches(*project_id)
|
||||
.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_id, 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_id).await.unwrap();
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert_eq!(branches[0].id, branch1_id);
|
||||
assert_eq!(branches[0].commits.len(), 3);
|
||||
|
@ -14,7 +14,7 @@ async fn should_fail_on_incorrect_branch() {
|
||||
|
||||
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_id).await;
|
||||
|
||||
let error = result.err();
|
||||
assert!(&error.is_some());
|
||||
|
@ -62,7 +62,7 @@ fn commit_on_branch_then_change_file_then_get_status() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"test commit",
|
||||
None,
|
||||
None,
|
||||
@ -160,7 +160,7 @@ fn track_binary_files() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"test commit",
|
||||
None,
|
||||
None,
|
||||
@ -191,7 +191,7 @@ fn track_binary_files() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"test commit",
|
||||
None,
|
||||
None,
|
||||
@ -231,7 +231,7 @@ fn create_branch_with_ownership() -> Result<()> {
|
||||
virtual_branches::get_status_by_branch(project_repository, None).expect("failed to get status");
|
||||
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
let branch0 = vb_state.get_branch(&branch0.id).unwrap();
|
||||
let branch0 = vb_state.get_branch(branch0.id).unwrap();
|
||||
|
||||
let branch1 = create_virtual_branch(
|
||||
project_repository,
|
||||
@ -471,12 +471,12 @@ fn move_hunks_multiple_sources() -> Result<()> {
|
||||
)?;
|
||||
|
||||
let vb_state = project.virtual_branches();
|
||||
let mut branch2 = vb_state.get_branch(&branch2_id)?;
|
||||
let mut branch2 = vb_state.get_branch(branch2_id)?;
|
||||
branch2.ownership = BranchOwnershipClaims {
|
||||
claims: vec!["test.txt:1-5".parse()?],
|
||||
};
|
||||
vb_state.set_branch(branch2.clone())?;
|
||||
let mut branch1 = vb_state.get_branch(&branch1_id)?;
|
||||
let mut branch1 = vb_state.get_branch(branch1_id)?;
|
||||
branch1.ownership = BranchOwnershipClaims {
|
||||
claims: vec!["test.txt:11-15".parse()?],
|
||||
};
|
||||
@ -847,7 +847,7 @@ fn merge_vbranch_upstream_clean_rebase() -> Result<()> {
|
||||
assert_eq!(branch1.commits.len(), 1);
|
||||
// assert_eq!(branch1.upstream.as_ref().unwrap().commits.len(), 1);
|
||||
|
||||
integrate_upstream_commits(project_repository, &branch1.id, None)?;
|
||||
integrate_upstream_commits(project_repository, branch1.id, None)?;
|
||||
|
||||
let (branches, _) = virtual_branches::list_virtual_branches(project_repository)?;
|
||||
let branch1 = &branches[0];
|
||||
@ -973,7 +973,7 @@ async fn merge_vbranch_upstream_conflict() -> Result<()> {
|
||||
assert_eq!(branch1.commits.len(), 1);
|
||||
// assert_eq!(branch1.upstream.as_ref().unwrap().commits.len(), 1);
|
||||
|
||||
integrate_upstream_commits(project_repository, &branch1.id, None)?;
|
||||
integrate_upstream_commits(project_repository, branch1.id, None)?;
|
||||
|
||||
let (branches, _) = virtual_branches::list_virtual_branches(project_repository)?;
|
||||
let branch1 = &branches[0];
|
||||
@ -1001,7 +1001,7 @@ async fn merge_vbranch_upstream_conflict() -> Result<()> {
|
||||
// commit the merge resolution
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1.id,
|
||||
branch1.id,
|
||||
"fix merge conflict",
|
||||
None,
|
||||
None,
|
||||
@ -1124,7 +1124,7 @@ fn unapply_branch() -> Result<()> {
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert!(branch.active);
|
||||
|
||||
virtual_branches::unapply_branch(project_repository, &branch1_id)?;
|
||||
virtual_branches::unapply_branch(project_repository, branch1_id)?;
|
||||
|
||||
let contents = std::fs::read(Path::new(&project.path).join(file_path))?;
|
||||
assert_eq!("line1\nline2\nline3\nline4\n", String::from_utf8(contents)?);
|
||||
@ -1136,7 +1136,7 @@ fn unapply_branch() -> Result<()> {
|
||||
assert_eq!(branch.files.len(), 1);
|
||||
assert!(!branch.active);
|
||||
|
||||
apply_branch(project_repository, &branch1_id, None)?;
|
||||
apply_branch(project_repository, branch1_id, None)?;
|
||||
let contents = std::fs::read(Path::new(&project.path).join(file_path))?;
|
||||
assert_eq!(
|
||||
"line1\nline2\nline3\nline4\nbranch1\n",
|
||||
@ -1200,20 +1200,20 @@ fn apply_unapply_added_deleted_files() -> Result<()> {
|
||||
},
|
||||
)?;
|
||||
|
||||
virtual_branches::unapply_branch(project_repository, &branch2_id)?;
|
||||
virtual_branches::unapply_branch(project_repository, branch2_id)?;
|
||||
// check that file2 is back
|
||||
let contents = std::fs::read(Path::new(&project.path).join(file_path2))?;
|
||||
assert_eq!("file2\n", String::from_utf8(contents)?);
|
||||
|
||||
virtual_branches::unapply_branch(project_repository, &branch3_id)?;
|
||||
virtual_branches::unapply_branch(project_repository, branch3_id)?;
|
||||
// check that file3 is gone
|
||||
assert!(!Path::new(&project.path).join(file_path3).exists());
|
||||
|
||||
apply_branch(project_repository, &branch2_id, None)?;
|
||||
apply_branch(project_repository, branch2_id, None)?;
|
||||
// check that file2 is gone
|
||||
assert!(!Path::new(&project.path).join(file_path2).exists());
|
||||
|
||||
apply_branch(project_repository, &branch3_id, None)?;
|
||||
apply_branch(project_repository, branch3_id, None)?;
|
||||
// check that file3 is back
|
||||
let contents = std::fs::read(Path::new(&project.path).join(file_path3))?;
|
||||
assert_eq!("file3\n", String::from_utf8(contents)?);
|
||||
@ -1265,8 +1265,8 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
.expect("failed to update branch");
|
||||
|
||||
// unapply both branches and create some conflicting ones
|
||||
virtual_branches::unapply_branch(project_repository, &branch1_id)?;
|
||||
virtual_branches::unapply_branch(project_repository, &branch2_id)?;
|
||||
virtual_branches::unapply_branch(project_repository, branch1_id)?;
|
||||
virtual_branches::unapply_branch(project_repository, branch2_id)?;
|
||||
|
||||
project_repository
|
||||
.git_repository
|
||||
@ -1346,7 +1346,7 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
|
||||
let vb_state = project.virtual_branches();
|
||||
|
||||
let mut branch4 = vb_state.get_branch(&branch4_id)?;
|
||||
let mut branch4 = vb_state.get_branch(branch4_id)?;
|
||||
branch4.ownership = BranchOwnershipClaims {
|
||||
claims: vec!["test2.txt:1-6".parse()?],
|
||||
};
|
||||
@ -1357,11 +1357,11 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
|
||||
let branch1 = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
||||
assert!(!branch1.active);
|
||||
assert!(!is_virtual_branch_mergeable(project_repository, &branch1.id).unwrap());
|
||||
assert!(!is_virtual_branch_mergeable(project_repository, branch1.id).unwrap());
|
||||
|
||||
let branch2 = &branches.iter().find(|b| b.id == branch2_id).unwrap();
|
||||
assert!(!branch2.active);
|
||||
assert!(is_virtual_branch_mergeable(project_repository, &branch2.id).unwrap());
|
||||
assert!(is_virtual_branch_mergeable(project_repository, branch2.id).unwrap());
|
||||
|
||||
let remotes = list_remote_branches(project_repository).expect("failed to list remotes");
|
||||
let _remote1 = &remotes
|
||||
@ -1498,7 +1498,7 @@ fn upstream_integrated_vbranch() -> Result<()> {
|
||||
// create a new virtual branch from the remote branch
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"integrated commit",
|
||||
None,
|
||||
None,
|
||||
@ -1506,7 +1506,7 @@ fn upstream_integrated_vbranch() -> Result<()> {
|
||||
)?;
|
||||
commit(
|
||||
project_repository,
|
||||
&branch2_id,
|
||||
branch2_id,
|
||||
"non-integrated commit",
|
||||
None,
|
||||
None,
|
||||
@ -1566,7 +1566,7 @@ fn commit_same_hunk_twice() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"first commit to test.txt",
|
||||
None,
|
||||
None,
|
||||
@ -1601,7 +1601,7 @@ fn commit_same_hunk_twice() -> Result<()> {
|
||||
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"second commit to test.txt",
|
||||
None,
|
||||
None,
|
||||
@ -1659,7 +1659,7 @@ fn commit_same_file_twice() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"first commit to test.txt",
|
||||
None,
|
||||
None,
|
||||
@ -1694,7 +1694,7 @@ fn commit_same_file_twice() -> Result<()> {
|
||||
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"second commit to test.txt",
|
||||
None,
|
||||
None,
|
||||
@ -1752,7 +1752,7 @@ fn commit_partial_by_hunk() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"first commit to test.txt",
|
||||
Some(&"test.txt:1-6".parse::<BranchOwnershipClaims>().unwrap()),
|
||||
None,
|
||||
@ -1770,7 +1770,7 @@ fn commit_partial_by_hunk() -> Result<()> {
|
||||
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"second commit to test.txt",
|
||||
Some(&"test.txt:16-22".parse::<BranchOwnershipClaims>().unwrap()),
|
||||
None,
|
||||
@ -1828,7 +1828,7 @@ fn commit_partial_by_file() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"branch1 commit",
|
||||
None,
|
||||
None,
|
||||
@ -1895,7 +1895,7 @@ fn commit_add_and_delete_files() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"branch1 commit",
|
||||
None,
|
||||
None,
|
||||
@ -1960,7 +1960,7 @@ fn commit_executable_and_symlinks() -> Result<()> {
|
||||
// commit
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"branch1 commit",
|
||||
None,
|
||||
None,
|
||||
@ -2137,7 +2137,7 @@ fn pre_commit_hook_rejection() -> Result<()> {
|
||||
|
||||
let res = commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"test commit",
|
||||
None,
|
||||
None,
|
||||
@ -2201,7 +2201,7 @@ fn post_commit_hook() -> Result<()> {
|
||||
|
||||
commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"test commit",
|
||||
None,
|
||||
None,
|
||||
@ -2249,7 +2249,7 @@ fn commit_msg_hook_rejection() -> Result<()> {
|
||||
|
||||
let res = commit(
|
||||
project_repository,
|
||||
&branch1_id,
|
||||
branch1_id,
|
||||
"test commit",
|
||||
None,
|
||||
None,
|
||||
|
@ -17,7 +17,7 @@ impl App {
|
||||
Self { projects }
|
||||
}
|
||||
|
||||
pub fn mark_resolved(&self, project_id: &ProjectId, path: &str) -> Result<(), CoreError> {
|
||||
pub fn mark_resolved(&self, project_id: ProjectId, path: &str) -> Result<(), CoreError> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
// mark file as resolved
|
||||
@ -27,7 +27,7 @@ impl App {
|
||||
|
||||
pub fn git_remote_branches(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<git::RemoteRefname>, CoreError> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
@ -36,7 +36,7 @@ impl App {
|
||||
|
||||
pub fn git_test_push(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
remote_name: &str,
|
||||
branch_name: &str,
|
||||
credentials: &git::credentials::Helper,
|
||||
@ -49,7 +49,7 @@ impl App {
|
||||
|
||||
pub fn git_test_fetch(
|
||||
&self,
|
||||
project_id: &ProjectId,
|
||||
project_id: ProjectId,
|
||||
remote_name: &str,
|
||||
credentials: &git::credentials::Helper,
|
||||
askpass: Option<String>,
|
||||
@ -59,7 +59,7 @@ impl App {
|
||||
Ok(project_repository.fetch(remote_name, credentials, askpass)?)
|
||||
}
|
||||
|
||||
pub fn git_index_size(&self, project_id: &ProjectId) -> Result<usize, CoreError> {
|
||||
pub fn git_index_size(&self, project_id: ProjectId) -> Result<usize, CoreError> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let size = project_repository
|
||||
@ -68,7 +68,7 @@ impl App {
|
||||
Ok(size)
|
||||
}
|
||||
|
||||
pub fn git_head(&self, project_id: &ProjectId) -> Result<String, CoreError> {
|
||||
pub fn git_head(&self, project_id: ProjectId) -> Result<String, CoreError> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = project_repository::Repository::open(&project)?;
|
||||
let head = project_repository
|
||||
@ -101,7 +101,7 @@ impl App {
|
||||
pub async fn delete_all_data(&self) -> Result<(), CoreError> {
|
||||
for project in self.projects.list().context("failed to list projects")? {
|
||||
self.projects
|
||||
.delete(&project.id)
|
||||
.delete(project.id)
|
||||
.await
|
||||
.map_err(|err| err.context("failed to delete project"))?;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub async fn git_remote_branches(
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<git::RemoteRefname>, Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
let branches = app.git_remote_branches(&project_id)?;
|
||||
let branches = app.git_remote_branches(project_id)?;
|
||||
Ok(branches)
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ pub async fn git_test_push(
|
||||
let app = handle.state::<app::App>();
|
||||
let helper = handle.state::<gitbutler_core::git::credentials::Helper>();
|
||||
Ok(app.git_test_push(
|
||||
&project_id,
|
||||
project_id,
|
||||
remote_name,
|
||||
branch_name,
|
||||
&helper,
|
||||
@ -47,7 +47,7 @@ pub async fn git_test_fetch(
|
||||
let app = handle.state::<app::App>();
|
||||
let helper = handle.state::<gitbutler_core::git::credentials::Helper>();
|
||||
Ok(app.git_test_fetch(
|
||||
&project_id,
|
||||
project_id,
|
||||
remote_name,
|
||||
&helper,
|
||||
Some(action.unwrap_or_else(|| "test".to_string())),
|
||||
@ -61,14 +61,14 @@ pub async fn git_index_size(
|
||||
project_id: ProjectId,
|
||||
) -> Result<usize, Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
Ok(app.git_index_size(&project_id).expect("git index size"))
|
||||
Ok(app.git_index_size(project_id).expect("git index size"))
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument(skip(handle), err(Debug))]
|
||||
pub async fn git_head(handle: tauri::AppHandle, project_id: ProjectId) -> Result<String, Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
let head = app.git_head(&project_id)?;
|
||||
let head = app.git_head(project_id)?;
|
||||
Ok(head)
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ pub async fn mark_resolved(
|
||||
path: &str,
|
||||
) -> Result<(), Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
app.mark_resolved(&project_id, path)?;
|
||||
app.mark_resolved(project_id, path)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ pub mod commands {
|
||||
) -> Result<projects::Project, Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.get(&id)
|
||||
.get(id)
|
||||
.map_err(Error::from_error_with_context)
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ pub mod commands {
|
||||
pub async fn set_project_active(handle: tauri::AppHandle, id: ProjectId) -> Result<(), Error> {
|
||||
let project = handle
|
||||
.state::<Controller>()
|
||||
.get(&id)
|
||||
.get(id)
|
||||
.context("project not found")?;
|
||||
Ok(handle.state::<Watchers>().watch(&project)?)
|
||||
}
|
||||
@ -71,7 +71,7 @@ pub mod commands {
|
||||
pub async fn delete_project(handle: tauri::AppHandle, id: ProjectId) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.delete(&id)
|
||||
.delete(id)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
@ -85,7 +85,7 @@ pub mod commands {
|
||||
) -> Result<Option<String>, Error> {
|
||||
Ok(handle
|
||||
.state::<Controller>()
|
||||
.get_local_config(&id, key)
|
||||
.get_local_config(id, key)
|
||||
.context(Code::Projects)?)
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
Ok(handle
|
||||
.state::<Controller>()
|
||||
.set_local_config(&id, key, value)
|
||||
.set_local_config(id, key, value)
|
||||
.context(Code::Projects)?)
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub async fn list_remotes(
|
||||
) -> Result<Vec<String>, Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.remotes(&project_id)
|
||||
.remotes(project_id)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
@ -26,7 +26,7 @@ pub async fn add_remote(
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.add_remote(&project_id, name, url)
|
||||
.add_remote(project_id, name, url)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ pub async fn list_snapshots(
|
||||
) -> Result<Vec<Snapshot>, Error> {
|
||||
let project = handle
|
||||
.state::<projects::Controller>()
|
||||
.get(&project_id)
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
let snapshots = project.list_snapshots(
|
||||
limit,
|
||||
@ -39,7 +39,7 @@ pub async fn restore_snapshot(
|
||||
) -> Result<(), Error> {
|
||||
let project = handle
|
||||
.state::<projects::Controller>()
|
||||
.get(&project_id)
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
project.restore_snapshot(sha.parse().map_err(anyhow::Error::from)?)?;
|
||||
Ok(())
|
||||
@ -54,7 +54,7 @@ pub async fn snapshot_diff(
|
||||
) -> Result<HashMap<PathBuf, FileDiff>, Error> {
|
||||
let project = handle
|
||||
.state::<projects::Controller>()
|
||||
.get(&project_id)
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
let diff = project.snapshot_diff(sha.parse().map_err(anyhow::Error::from)?)?;
|
||||
Ok(diff)
|
||||
|
@ -29,9 +29,9 @@ pub mod commands {
|
||||
) -> Result<git::Oid, Error> {
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
.create_commit(&project_id, &branch, message, ownership.as_ref(), run_hooks)
|
||||
.create_commit(project_id, branch, message, ownership.as_ref(), run_hooks)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(oid)
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ pub mod commands {
|
||||
) -> Result<VirtualBranches, Error> {
|
||||
let (branches, skipped_files) = handle
|
||||
.state::<Controller>()
|
||||
.list_virtual_branches(&project_id)
|
||||
.list_virtual_branches(project_id)
|
||||
.await?;
|
||||
|
||||
let proxy = handle.state::<assets::Proxy>();
|
||||
@ -63,9 +63,9 @@ pub mod commands {
|
||||
) -> Result<BranchId, Error> {
|
||||
let branch_id = handle
|
||||
.state::<Controller>()
|
||||
.create_virtual_branch(&project_id, &branch)
|
||||
.create_virtual_branch(project_id, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(branch_id)
|
||||
}
|
||||
|
||||
@ -78,9 +78,9 @@ pub mod commands {
|
||||
) -> Result<BranchId, Error> {
|
||||
let branch_id = handle
|
||||
.state::<Controller>()
|
||||
.create_virtual_branch_from_branch(&project_id, &branch)
|
||||
.create_virtual_branch_from_branch(project_id, &branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(branch_id)
|
||||
}
|
||||
|
||||
@ -93,9 +93,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.integrate_upstream_commits(&project_id, &branch)
|
||||
.integrate_upstream_commits(project_id, branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ pub mod commands {
|
||||
) -> Result<Option<BaseBranch>, Error> {
|
||||
if let Ok(base_branch) = handle
|
||||
.state::<Controller>()
|
||||
.get_base_branch_data(&project_id)
|
||||
.get_base_branch_data(project_id)
|
||||
.await
|
||||
{
|
||||
let proxy = handle.state::<assets::Proxy>();
|
||||
@ -130,7 +130,7 @@ pub mod commands {
|
||||
.context("Invalid branch name")?;
|
||||
let base_branch = handle
|
||||
.state::<Controller>()
|
||||
.set_base_branch(&project_id, &branch_name)
|
||||
.set_base_branch(project_id, &branch_name)
|
||||
.await?;
|
||||
let base_branch = handle
|
||||
.state::<assets::Proxy>()
|
||||
@ -141,10 +141,10 @@ 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_id, push_remote)
|
||||
.await?;
|
||||
}
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(base_branch)
|
||||
}
|
||||
|
||||
@ -153,9 +153,9 @@ pub mod commands {
|
||||
pub async fn update_base_branch(handle: AppHandle, project_id: ProjectId) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.update_base_branch(&project_id)
|
||||
.update_base_branch(project_id)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -168,10 +168,10 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.update_virtual_branch(&project_id, branch)
|
||||
.update_virtual_branch(project_id, branch)
|
||||
.await?;
|
||||
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -184,9 +184,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.delete_virtual_branch(&project_id, &branch_id)
|
||||
.delete_virtual_branch(project_id, branch_id)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -199,9 +199,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.apply_virtual_branch(&project_id, &branch)
|
||||
.apply_virtual_branch(project_id, branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -214,9 +214,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.unapply_virtual_branch(&project_id, &branch)
|
||||
.unapply_virtual_branch(project_id, branch)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -229,9 +229,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.unapply_ownership(&project_id, &ownership)
|
||||
.unapply_ownership(project_id, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -249,9 +249,9 @@ pub mod commands {
|
||||
.collect::<Vec<String>>();
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.reset_files(&project_id, &files)
|
||||
.reset_files(project_id, &files)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -265,10 +265,10 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.push_virtual_branch(&project_id, &branch_id, with_force, Some(Some(branch_id)))
|
||||
.push_virtual_branch(project_id, branch_id, with_force, Some(Some(branch_id)))
|
||||
.await
|
||||
.map_err(|err| err.context(Code::Unknown))?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ pub mod commands {
|
||||
) -> Result<bool, Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.can_apply_virtual_branch(&project_id, &branch_id)
|
||||
.can_apply_virtual_branch(project_id, branch_id)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
@ -295,7 +295,7 @@ pub mod commands {
|
||||
) -> Result<bool, Error> {
|
||||
Ok(handle
|
||||
.state::<Controller>()
|
||||
.can_apply_remote_branch(&project_id, &branch)
|
||||
.can_apply_remote_branch(project_id, &branch)
|
||||
.await?)
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ pub mod commands {
|
||||
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.list_remote_commit_files(&project_id, commit_oid)
|
||||
.list_remote_commit_files(project_id, commit_oid)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
@ -323,9 +323,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.reset_virtual_branch(&project_id, &branch_id, target_commit_oid)
|
||||
.reset_virtual_branch(project_id, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -339,9 +339,9 @@ pub mod commands {
|
||||
) -> Result<Option<git::Oid>, Error> {
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
.cherry_pick(&project_id, &branch_id, target_commit_oid)
|
||||
.cherry_pick(project_id, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(oid)
|
||||
}
|
||||
|
||||
@ -356,9 +356,9 @@ pub mod commands {
|
||||
) -> Result<git::Oid, Error> {
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
.amend(&project_id, &branch_id, commit_oid, &ownership)
|
||||
.amend(project_id, branch_id, commit_oid, &ownership)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(oid)
|
||||
}
|
||||
|
||||
@ -375,14 +375,14 @@ pub mod commands {
|
||||
let oid = handle
|
||||
.state::<Controller>()
|
||||
.move_commit_file(
|
||||
&project_id,
|
||||
&branch_id,
|
||||
project_id,
|
||||
branch_id,
|
||||
from_commit_oid,
|
||||
to_commit_oid,
|
||||
&ownership,
|
||||
)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(oid)
|
||||
}
|
||||
|
||||
@ -396,9 +396,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.undo_commit(&project_id, &branch_id, commit_oid)
|
||||
.undo_commit(project_id, branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -413,9 +413,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.insert_blank_commit(&project_id, &branch_id, commit_oid, offset)
|
||||
.insert_blank_commit(project_id, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -430,9 +430,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.reorder_commit(&project_id, &branch_id, commit_oid, offset)
|
||||
.reorder_commit(project_id, branch_id, commit_oid, offset)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -444,7 +444,7 @@ pub mod commands {
|
||||
) -> Result<Vec<RemoteBranch>, Error> {
|
||||
let branches = handle
|
||||
.state::<Controller>()
|
||||
.list_remote_branches(&project_id)
|
||||
.list_remote_branches(project_id)
|
||||
.await?;
|
||||
Ok(branches)
|
||||
}
|
||||
@ -458,7 +458,7 @@ pub mod commands {
|
||||
) -> Result<RemoteBranchData, Error> {
|
||||
let branch_data = handle
|
||||
.state::<Controller>()
|
||||
.get_remote_branch_data(&project_id, &refname)
|
||||
.get_remote_branch_data(project_id, &refname)
|
||||
.await?;
|
||||
let branch_data = handle
|
||||
.state::<assets::Proxy>()
|
||||
@ -477,9 +477,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.squash(&project_id, &branch_id, target_commit_oid)
|
||||
.squash(project_id, branch_id, target_commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -493,11 +493,11 @@ pub mod commands {
|
||||
let base_branch = handle
|
||||
.state::<Controller>()
|
||||
.fetch_from_remotes(
|
||||
&project_id,
|
||||
project_id,
|
||||
Some(action.unwrap_or_else(|| "unknown".to_string())),
|
||||
)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(base_branch)
|
||||
}
|
||||
|
||||
@ -511,9 +511,9 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.move_commit(&project_id, &target_branch_id, commit_oid)
|
||||
.move_commit(project_id, target_branch_id, commit_oid)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -528,17 +528,17 @@ pub mod commands {
|
||||
) -> Result<(), Error> {
|
||||
handle
|
||||
.state::<Controller>()
|
||||
.update_commit_message(&project_id, &branch_id, commit_oid, message)
|
||||
.update_commit_message(project_id, branch_id, commit_oid, message)
|
||||
.await?;
|
||||
emit_vbranches(&handle, &project_id).await;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn emit_vbranches(handle: &AppHandle, project_id: &projects::ProjectId) {
|
||||
async fn emit_vbranches(handle: &AppHandle, project_id: projects::ProjectId) {
|
||||
if let Err(error) = handle
|
||||
.state::<watcher::Watchers>()
|
||||
.post(gitbutler_watcher::Action::CalculateVirtualBranches(
|
||||
*project_id,
|
||||
project_id,
|
||||
))
|
||||
.await
|
||||
{
|
||||
|
@ -103,10 +103,9 @@ impl Watchers {
|
||||
pub fn watch(&self, project: &projects::Project) -> Result<()> {
|
||||
let handler = handler_from_app(&self.app_handle)?;
|
||||
|
||||
let project_id = project.id;
|
||||
let project_path = project.path.clone();
|
||||
|
||||
let handle = gitbutler_watcher::watch_in_background(handler, project_path, project_id)?;
|
||||
let handle = gitbutler_watcher::watch_in_background(handler, project_path, project.id)?;
|
||||
block_on(self.watcher.lock()).replace(handle);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ pub mod commands {
|
||||
))?;
|
||||
handle
|
||||
.state::<controller::Controller>()
|
||||
.archive(&project_id)
|
||||
.archive(project_id)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ pub mod commands {
|
||||
))?;
|
||||
handle
|
||||
.state::<controller::Controller>()
|
||||
.data_archive(&project_id)
|
||||
.data_archive(project_id)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ impl Case {
|
||||
pub fn refresh(mut self, suite: &Suite) -> Self {
|
||||
let project = suite
|
||||
.projects
|
||||
.get(&self.project.id)
|
||||
.get(self.project.id)
|
||||
.expect("failed to get project");
|
||||
let project_repository = gitbutler_core::project_repository::Repository::open(&project)
|
||||
.expect("failed to create project repository");
|
||||
|
@ -86,7 +86,7 @@ impl Handler {
|
||||
async fn calculate_virtual_branches(&self, project_id: ProjectId) -> Result<()> {
|
||||
match self
|
||||
.vbranch_controller
|
||||
.list_virtual_branches(&project_id)
|
||||
.list_virtual_branches(project_id)
|
||||
.await
|
||||
{
|
||||
Ok((branches, skipped_files)) => {
|
||||
@ -123,7 +123,7 @@ impl Handler {
|
||||
fn maybe_create_snapshot(&self, project_id: ProjectId) -> anyhow::Result<()> {
|
||||
let project = self
|
||||
.projects
|
||||
.get(&project_id)
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
if project
|
||||
.should_auto_snapshot(std::time::Duration::from_secs(300))
|
||||
@ -145,7 +145,7 @@ impl Handler {
|
||||
pub async fn git_files_change(&self, paths: Vec<PathBuf>, project_id: ProjectId) -> Result<()> {
|
||||
let project = self
|
||||
.projects
|
||||
.get(&project_id)
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
let open_projects_repository = || {
|
||||
project_repository::Repository::open(&project)
|
||||
@ -197,7 +197,7 @@ impl Handler {
|
||||
async fn gitbutler_oplog_change(&self, project_id: ProjectId) -> Result<()> {
|
||||
let project = self
|
||||
.projects
|
||||
.get(&project_id)
|
||||
.get(project_id)
|
||||
.context("failed to get project")?;
|
||||
|
||||
if project.is_sync_enabled() && project.has_code_url() {
|
||||
|
Loading…
Reference in New Issue
Block a user