Merge pull request #4536 from gitbutlerapp/fix-broken-condition

Fix gitbutler/integration nuking itself
This commit is contained in:
Caleb Owens 2024-07-29 19:26:20 +02:00 committed by GitHub
commit 7339c0bb19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -30,9 +30,9 @@ pub fn in_outside_workspace_mode(ctx: &CommandContext) -> Result<bool> {
}
pub fn assure_outside_workspace_mode(ctx: &CommandContext) -> Result<()> {
if in_open_workspace_mode(ctx)? {
if in_outside_workspace_mode(ctx)? {
Ok(())
} else {
bail!("Unexpected state: cannot perform operation on non-integration branch")
bail!("Unexpected state: cannot perform operation on integration branch")
}
}

View File

@ -4,7 +4,7 @@ use anyhow::{Context, Result};
use gitbutler_branch_actions::{VirtualBranchActions, VirtualBranches};
use gitbutler_command_context::CommandContext;
use gitbutler_error::error::Marker;
use gitbutler_operating_modes::in_open_workspace_mode;
use gitbutler_operating_modes::{in_open_workspace_mode, in_outside_workspace_mode};
use gitbutler_oplog::{
entry::{OperationKind, SnapshotDetails},
OplogExt,
@ -171,7 +171,10 @@ impl Handler {
"HEAD" => {
let ctx = CommandContext::open(&project)
.context("Failed to create a command context")?;
if in_open_workspace_mode(&ctx)? {
// If the user has left gitbutler/integration, we want to delete the reference.
// TODO: why do we want to do this?
if in_outside_workspace_mode(&ctx)? {
let mut integration_reference = ctx.repository().find_reference(
&Refname::from(LocalRefname::new("gitbutler/integration", None))
.to_string(),