diff mbox series

[b4,1/3] ez: allow iterations to be sent in a single thread

Message ID 20230219-send-iterations-in-same-thread-v1-1-59b802382eb5@gmail.com (mailing list archive)
State Superseded
Headers show
Series ez: allow sending all versions of a patch series in the same thread | expand

Commit Message

Philippe Blain Feb. 22, 2023, 1:29 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 optional argument to get_prep_branch_as_patches, 'samethread',
defaulting to False. 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.

This functionality will be exposed to users in a following commit.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 b4/ez.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/b4/ez.py b/b4/ez.py
index 74afddc..dac5e2a 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -1117,7 +1117,8 @@  def get_mailfrom() -> Tuple[str, str]:
     return usercfg.get('name'), usercfg.get('email')
 
 
-def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtracking: bool = True
+def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtracking: bool = True,
+                               samethread: bool = False
                                ) -> Tuple[List, List, str, List[Tuple[str, email.message.Message]]]:
     cover, tracking = load_cover(strip_comments=True)
 
@@ -1191,6 +1192,12 @@  def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtr
     if addtracking:
         patches[0][1].add_header('X-B4-Tracking', thdata)
 
+    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