diff mbox series

[b4,v2] ez: allow sending all versions of a patch series in the same thread

Message ID 20230219-send-iterations-in-same-thread-v2-1-3ae4ac504e07@gmail.com (mailing list archive)
State Accepted
Headers show
Series [b4,v2] ez: allow sending all versions of a patch series in the same thread | expand

Commit Message

Philippe Blain Feb. 24, 2023, 1:14 a.m. UTC
Some projects prefer further iterations of a patch series to be sent in
the same thread as previous ones. Usually this means that the cover
letter of v2 is sent as a reply to the cover letter of v1, etc.

Add a new config option for 'b4 send', 'send-same-thread', defaulting to
False, and read its value in get_prep_branch_as_patches. When True, add
an 'In-Reply-To' header to the first mail in the series, referencing the
Message-ID of the previous iterations's cover letter.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
Changes in v2:
- removed the command-line flag and kept only the config, as suggested
  by Konstantin
- Link to v1: https://msgid.link/20230219-send-iterations-in-same-thread-v1-0-59b802382eb5@gmail.com

v1:
Sending a new iteration of a series in the same thread as the previous
one is the preferred workflow on some lists, the Git mailing list being
an example [1].

This series allows that workflow in b4 by adding a '--same-thread'
option to 'b4 send', with an associated config option.

Cheers,

Philippe.

[1] https://git-scm.com/docs/MyFirstContribution#v2-git-send-email
---
 b4/ez.py        | 7 +++++++
 docs/config.rst | 6 ++++++
 2 files changed, 13 insertions(+)


---
base-commit: a3281834d6d5dec44f58071fca2d22e04a97fe18
change-id: 20230219-send-iterations-in-same-thread-c50a3bc4ed9e
--
b4
diff mbox series

Patch

diff --git a/b4/ez.py b/b4/ez.py
index 74afddc..16e1cf8 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -1191,6 +1191,13 @@  def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtr
     if addtracking:
         patches[0][1].add_header('X-B4-Tracking', thdata)
 
+    samethread = config.get('send-same-thread', '').lower() in {'yes', 'true', 'y'}
+    if samethread and revision > 1:
+        oldrev = revision - 1
+        voldrev =  f'v{oldrev}'
+        oldmsgid =  tracking['series']['history'][voldrev][-1]
+        patches[0][1].add_header('In-Reply-To', f'<{oldmsgid}>')
+
     tag_msg = f'{csubject.full_subject}\n\n{cover_letter}'
     return alltos, allccs, tag_msg, patches
 
diff --git a/docs/config.rst b/docs/config.rst
index b3ab5ca..a1c424c 100644
--- a/docs/config.rst
+++ b/docs/config.rst
@@ -351,6 +351,12 @@  Contributor-oriented settings
 
   Default:: ``scripts/get_maintainer.pl --nogit --nogit-fallback --nogit-chief-penguins --norolestats --nom``
 
+``b4.send-same-thread`` (v0.13+)
+  When sending a new version of a series, make it part of the same
+  thread as the previous one. The first mail will be sent as a reply
+  to the previous version's cover letter.
+
+  Default: ``no``
 
 ``b4.prep-cover-strategy`` (v0.10+)
   Alternative cover letter storage strategy to use (see :ref:`prep_cover_strategies`).