mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 02:26:14 +03:00
fix a bug where deleting a vbranch fails to update state
This commit is contained in:
parent
dfa38908f9
commit
310d4cf73a
@ -40,11 +40,6 @@ impl BranchManager<'_> {
|
||||
|
||||
self.delete_branch(branch_id, perm, &target_commit)?;
|
||||
|
||||
// If we were conflicting, it means that it was the only branch applied. Since we've now unapplied it we can clear all conflicts
|
||||
if conflicts::is_conflicting(self.ctx, None)? {
|
||||
conflicts::clear(self.ctx)?;
|
||||
}
|
||||
|
||||
vb_state.update_ordering()?;
|
||||
|
||||
// Ensure we still have a default target
|
||||
@ -137,6 +132,13 @@ impl BranchManager<'_> {
|
||||
vbranch::ensure_selected_for_changes(&vb_state)
|
||||
.context("failed to ensure selected for changes")?;
|
||||
|
||||
// If we were conflicting, it means that it was the only branch applied. Since we've now unapplied it we can clear all conflicts
|
||||
if conflicts::is_conflicting(self.ctx, None)? {
|
||||
conflicts::clear(self.ctx)?;
|
||||
}
|
||||
crate::integration::update_workspace_commit(&vb_state, self.ctx)
|
||||
.context("failed to update gitbutler workspace")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,14 @@ fn should_unapply_diff() {
|
||||
std::fs::write(repository.path().join("file.txt"), "content").unwrap();
|
||||
|
||||
let (branches, _) = gitbutler_branch_actions::list_virtual_branches(project).unwrap();
|
||||
let c = gitbutler_branch_actions::create_commit(
|
||||
project,
|
||||
branches.first().unwrap().id,
|
||||
"asdf",
|
||||
None,
|
||||
false,
|
||||
);
|
||||
assert!(c.is_ok());
|
||||
|
||||
gitbutler_branch_actions::delete_virtual_branch(project, branches[0].id).unwrap();
|
||||
|
||||
@ -27,6 +35,14 @@ fn should_unapply_diff() {
|
||||
assert_eq!(branches.len(), 0);
|
||||
assert!(!repository.path().join("file.txt").exists());
|
||||
|
||||
let mut opts = git2::StatusOptions::new();
|
||||
opts.include_untracked(true);
|
||||
let statuses = repository
|
||||
.local_repository
|
||||
.statuses(Some(&mut opts))
|
||||
.unwrap();
|
||||
assert!(statuses.is_empty());
|
||||
|
||||
let refnames = repository
|
||||
.references()
|
||||
.into_iter()
|
||||
|
@ -10,7 +10,7 @@ pub fn temp_dir() -> TempDir {
|
||||
}
|
||||
|
||||
pub struct TestProject {
|
||||
local_repository: git2::Repository,
|
||||
pub local_repository: git2::Repository,
|
||||
local_tmp: Option<TempDir>,
|
||||
remote_repository: git2::Repository,
|
||||
remote_tmp: Option<TempDir>,
|
||||
|
Loading…
Reference in New Issue
Block a user