mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 22:03:30 +03:00
update_base_branch returns unapplied branches list
If merge conflicts caused branches to become unapplied, return them as a list
This commit is contained in:
parent
ad4d94208b
commit
d164457299
@ -336,7 +336,7 @@ fn _print_tree(repo: &git2::Repository, tree: &git2::Tree) -> Result<()> {
|
||||
pub fn update_base_branch(
|
||||
project_repository: &project_repository::Repository,
|
||||
user: Option<&users::User>,
|
||||
) -> anyhow::Result<()> {
|
||||
) -> anyhow::Result<Vec<branch::Branch>> {
|
||||
if project_repository.is_resolving() {
|
||||
anyhow::bail!(errors::UpdateBaseBranchError::Conflict(
|
||||
errors::ProjectConflict {
|
||||
@ -356,8 +356,10 @@ pub fn update_base_branch(
|
||||
.peel_to_commit()
|
||||
.context(format!("failed to peel branch {} to commit", target.branch))?;
|
||||
|
||||
let mut unapplied_branches: Vec<branch::Branch> = Vec::new();
|
||||
|
||||
if new_target_commit.id() == target.sha.into() {
|
||||
return Ok(());
|
||||
return Ok(unapplied_branches);
|
||||
}
|
||||
|
||||
let new_target_tree = new_target_commit
|
||||
@ -433,6 +435,7 @@ pub fn update_base_branch(
|
||||
// branch tree conflicts with new target, unapply branch for now. we'll handle it later, when user applies it back.
|
||||
branch.applied = false;
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
unapplied_branches.push(branch.clone());
|
||||
return Ok(Some(branch));
|
||||
}
|
||||
|
||||
@ -569,7 +572,7 @@ pub fn update_base_branch(
|
||||
|
||||
// Rewriting the integration commit is necessary after changing target sha.
|
||||
super::integration::update_gitbutler_integration(&vb_state, project_repository)?;
|
||||
Ok(())
|
||||
Ok(unapplied_branches)
|
||||
}
|
||||
|
||||
pub fn target_to_base_branch(
|
||||
|
@ -9,8 +9,8 @@ use tokio::{sync::Semaphore, task::JoinHandle};
|
||||
|
||||
use super::{
|
||||
branch::{BranchId, BranchOwnershipClaims},
|
||||
errors::{self},
|
||||
target, target_to_base_branch, BaseBranch, RemoteBranchFile, VirtualBranchesHandle,
|
||||
errors, target, target_to_base_branch, BaseBranch, Branch, RemoteBranchFile,
|
||||
VirtualBranchesHandle,
|
||||
};
|
||||
use crate::{
|
||||
git, project_repository,
|
||||
@ -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<Vec<Branch>, Error> {
|
||||
self.inner(project_id)
|
||||
.await
|
||||
.update_base_branch(project_id)
|
||||
@ -587,7 +587,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<Vec<Branch>, Error> {
|
||||
let _permit = self.semaphore.acquire().await;
|
||||
|
||||
self.with_verify_branch(project_id, |project_repository, user| {
|
||||
|
@ -150,13 +150,16 @@ pub mod commands {
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument(skip(handle), err(Debug))]
|
||||
pub async fn update_base_branch(handle: AppHandle, project_id: ProjectId) -> Result<(), Error> {
|
||||
handle
|
||||
pub async fn update_base_branch(
|
||||
handle: AppHandle,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<branch::Branch>, Error> {
|
||||
let unapplied_branches = handle
|
||||
.state::<Controller>()
|
||||
.update_base_branch(project_id)
|
||||
.await?;
|
||||
emit_vbranches(&handle, project_id).await;
|
||||
Ok(())
|
||||
Ok(unapplied_branches)
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
|
@ -780,7 +780,7 @@ mod tests {
|
||||
|
||||
for (delay, events) in expected_events {
|
||||
MockClock::set_time(backup_time);
|
||||
state.queues = backup_queues.clone();
|
||||
state.queues.clone_from(&backup_queues);
|
||||
|
||||
match delay.as_str() {
|
||||
"none" => {}
|
||||
|
@ -192,7 +192,7 @@ mod utils {
|
||||
fn add_path(&mut self, path: &Path) {
|
||||
for (p, file_id) in &self.file_system {
|
||||
if p.starts_with(path) {
|
||||
self.paths.insert(p.clone(), file_id.clone());
|
||||
self.paths.insert(p.clone(), *file_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ mod utils {
|
||||
}
|
||||
|
||||
fn rescan(&mut self) {
|
||||
self.add_path(&Path::new("/"));
|
||||
self.add_path(Path::new("/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user