ez: add "file" cover letter strategy
PATCH 1/1 ez: add "file" cover letter strategy
From: Chuck Lever <[email protected]>
The branch-description cover strategy stores the cover letter, changelog, and recipient list as a single blob in .git/config under the branch description key. This is unwieldy: the blob cannot be edited by hand, tools such as "stg branch --list" dump the entire cover letter for every prepped branch, and auto-to-cc writes recipient trailers directly into the cover letter prose where they risk corruption on regeneration.
Add a new "file" strategy that stores these three concerns in separate plain text files under .git/b4-prep/<change-id>/:
cover -- subject, body, and non-address trailers changelog -- version history below the --- separator recipients -- To: and Cc: lines from --auto-to-cc
Tracking metadata (revision, change-id, base-branch) remains in .git/config as with branch-description. The load path assembles the three files into the combined cover text that all downstream code expects, so no other functions require modification. The store path splits the combined text back into the three files using LoreMessage.get_body_parts() to separate address trailers from cover body content.
--- docs/contributor/prep.rst | 29 +++++++++ src/b4/ez.py | 127 +++++++++++++++++++++++++++++++++++++- 2 files changed, 153 insertions(+), 3 deletions(-)
docs/contributor/prep.rst +29 -0
@@ -96,6 +96,35 @@ cover letter. You can tell ``b4`` which strategy to use using the * you have to rely on the base branch for keeping track of where your series starts +``file`` strategy + This keeps the cover letter, changelog, and recipients in separate + plain text files under ``.git/b4-prep/<change-id>/``. Tracking + metadata (revision, change-id, base-branch) remains in + ``.git/config`` as with ``branch-description``. + + The directory contains three files: + + * ``cover`` -- the cover letter subject, body, and non-address trailers + * ``changelog`` -- version history entries (below the ``---`` separator) + * ``recipients`` -- ``To:`` and ``Cc:`` lines populated by ``--auto-to-cc`` + + Upsides: + + * each file is plain text, directly editable with any text editor + * editing the cover letter doesn't rewrite commit history + * ``--auto-to-cc`` writes to ``recipients`` without touching the cover + letter body, so regenerating addresses can't corrupt prose + * compatible with tools like Stacked Git that manage commits + independently + * ``stg branch --list`` is not cluttered with cover letter text + + Downsides: + + * the cover letter only exists local to your tree -- you won't be + able to commit it to the repository and push it remotely + * you have to rely on the base branch for keeping track of where your + series starts + ``tip-commit`` strategy This is similar to the default ``commit`` strategy, but instead of keeping the cover letter and all tracking information in an empty
src/b4/ez.py +124 -3
180 lines not on this page · raw message
Signature · 1 line
2.53.0