Skip to content

Commit

Permalink
Merge pull request #1841 from timbrel/fix-not-merged-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste authored Dec 20, 2023
2 parents 04d78b2 + 7764734 commit 923105e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/commands/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"""

EXTRACT_COMMIT = re.compile(r"\(was (.+)\)")
NOT_MERGED_WARNING = re.compile(r"The branch.*is not fully merged\.")
CANT_DELETE_CURRENT_BRANCH = re.compile(r"Cannot delete branch .+ checked out at ")
NOT_MERGED_WARNING = re.compile(r"the branch.*is not fully merged\.", re.I)
CANT_DELETE_USED_BRANCH = re.compile(r"cannot delete branch .+ (checked out|used by worktree) at ", re.I)


def just(value):
Expand Down Expand Up @@ -172,7 +172,10 @@ def run(self, branch, force=False):
if NOT_MERGED_WARNING.search(e.stderr):
self.offer_force_deletion(branch)
return
if CANT_DELETE_CURRENT_BRANCH.search(e.stderr):
if (
CANT_DELETE_USED_BRANCH.search(e.stderr)
and branch == self.get_current_branch_name()
):
self.offer_detaching_head(branch)
return
e.show_error_panel()
Expand Down

0 comments on commit 923105e

Please sign in to comment.