[PATCH b4 12/27] review-tui: use the shared helper to delete a review branch
Christian Brauner <[email protected]> Fri, 31 Jul 2026 11:21:11 +0200
| Newsgroups | org.kernel.linux.tools |
|---|---|
| Message-ID | <20260731-work-b4-editor-branch-guard-v1-12-de68a7c8e4cb@kernel.org> |
Archiving a series moved into b4.review.archive_series() and took the branch deletion with it as delete_review_branch(). The tracking UI kept its own copy for the abandon path, so the same three steps exist twice and differ only in whether a failure comes back as a notification or as a string. Make the one in the TUI a wrapper that turns the string into a notification. It is interactive, so it passes allow_switch. Detaching to get off the branch is what the abandon dialog already asked about. 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 7572a95..99964d0 100644 --- a/src/b4/review_tui/_tracking_app.py +++ b/src/b4/review_tui/_tracking_app.py @@ -3781,36 +3781,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