prep: add --cleanup-older-than option to clean up stale branches
PATCH v2 1/1 prep: add --cleanup-older-than option to clean up stale branches
B4 is so useful that I have too many branches now, create a way to easily remove old branches.
Add a new --cleanup-older-than DAYS option that archives and removes prep-tracked branches whose latest commit is older than the specified number of days. Each matching branch goes through the normal per-branch confirmation prompt.
---
Changes in v2:
- Rebased onto master; option moved into exclusive group, help clarified.
- Age no longer truncated to whole days
- Documented in prep.rst.
- Link to v1: https://patch.msgid.link/[email protected]
--- docs/contributor/prep.rst | 18 ++++++++++++++++++ src/b4/command.py | 7 +++++++ src/b4/ez.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+)
docs/contributor/prep.rst +18 -0
@@ -354,6 +354,16 @@ patches, cover letters, and tracking information from your series. Afterwards, b4 deletes the branch(es) and all related tags from your local repository. +If prep-managed branches have piled up over time, you can select them by +age instead of by name:: + + b4 prep --cleanup-older-than 180 + +This finds every prep-managed branch whose latest commit is older than the +given number of days, skipping the one you currently have checked out. Each +matching branch is then archived and deleted through the same confirmation +prompt as above, so nothing goes away without your say-so. + .. _prep_flags: Prep command flags
@@ -522,6 +532,14 @@ modifying defaults for some of these flags. .. versionadded:: v0.13 +``--cleanup-older-than DAYS`` + Same as ``--cleanup``, but picks the branches by age rather than by + name: every prep-managed branch whose latest commit is older than + DAYS days is archived and deleted, one confirmation prompt at a time. + The currently checked out branch is always left alone. + + .. versionadded:: v0.16 + ``--claim [BRANCH]`` Re-stamps the cover letter and every patch on a prep branch under your current git identity (defaults to the current branch). B4
src/b4/command.py +7 -0
@@ -1010,6 +1010,13 @@ def setup_parser() -> argparse.ArgumentParser: nargs='*', help='Archive and remove prep-tracked branches and all associated sent/ tags', ) + spp_g.add_argument( + '--cleanup-older-than', + metavar='DAYS', + type=int, + default=None, + help='Archive and remove prep-tracked branches older than DAYS days', + ) spp_g.add_argument( '--claim', metavar='BRANCH',
src/b4/ez.py +43 -0
55 lines not on this page · raw message
---
base-commit: 62c5a3c2f841dd6533a9009e6ab4fee104bf3b04
change-id: 20260323-cleanup-4dea45140971
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
Konstantin Ryabitsev
AppliedQuoted 1 line · Breno Leitao
prep: add --cleanup-older-than option to clean up stale branches
Applied, thanks!
[1/1] prep: add --cleanup-older-than option to clean up stale branches
commit: 69f3df3954f387b408bab999d36452cafcc5120d
Best regards,
Signature · 1 line
Konstantin Ryabitsev <[email protected]>