[PATCH b4 v2 12/44] review-tui: use the shared helper to delete a review branch

Christian Brauner <[email protected]> Fri, 31 Jul 2026 23:58:53 +0200
Newsgroups org.kernel.linux.tools
Message-ID <20260731-work-b4-editor-branch-guard-v2-12-243fd19d322d@kernel.org>
The tracking UI kept its own copy of the branch deletion that moved
into b4.review as delete_review_branch(). Make the TUI copy a wrapper
that turns the error string into a notification.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 src/b4/review_tui/_tracking_app.py | 36 +++++++++---------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/src/b4/review_tui/_tracking_app.py b/src/b4/review_tui/_tracking_app.py
index 83e33c7..a20eaa4 100644
--- a/src/b4/review_tui/_tracking_app.py
+++ b/src/b4/review_tui/_tracking_app.py
@@ -3791,36 +3791,18 @@ class TrackingApp(LoreNodeShutdownMixin, CheckRunnerMixin, App[Optional[str]]):
     ) -> bool:
         """Delete a review branch, switching away if currently on it.
 
+        Thin TUI wrapper around b4.review.delete_review_branch() that turns
+        its error string into a notification.  Interactive, so detaching HEAD
+        to get off the branch is fine here.
+
         Returns True on success, False on failure.
         """
-        if b4.git_get_current_branch(topdir) == review_branch:
-            ecode, out = b4.git_run_command(
-                topdir, ['rev-parse', f'{review_branch}~1'], logstderr=True
-            )
-            if ecode > 0:
-                if notify:
-                    self.notify('Could not determine parent commit', severity='error')
-                return False
-            parent = out.strip()
-            ecode, out = b4.git_run_command(
-                topdir, ['checkout', parent], logstderr=True
-            )
-            if ecode > 0:
-                if notify:
-                    self.notify(
-                        f'Could not switch away from {review_branch}', severity='error'
-                    )
-                return False
-        ecode, out = b4.git_run_command(
-            topdir, ['branch', '-D', review_branch], logstderr=True
+        ok, err = b4.review.delete_review_branch(
+            topdir, review_branch, allow_switch=True
         )
-        if ecode > 0:
-            if notify:
-                self.notify(
-                    f'Failed to delete branch {review_branch}', severity='error'
-                )
-            return False
-        return True
+        if not ok and notify:
+            self.notify(err, severity='error')
+        return ok
 
     def action_abandon(self) -> None:
         """Abandon the selected series."""

-- 
2.53.0