Jeremy White : Make event subjects match the MR cover letter.

Alexandre Julliard julliard at winehq.org
Thu May 5 01:07:53 CDT 2022


Module: tools
Branch: master
Commit: 58a574fcad7161adf6213c0fed85fdabfda2134b
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=58a574fcad7161adf6213c0fed85fdabfda2134b

Author: Jeremy White <jwhite at codeweavers.com>
Date:   Tue May  3 14:30:45 2022 -0500

Make event subjects match the MR cover letter.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 gitlab/gitlab-to-mail/gitlabtomail.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/gitlab/gitlab-to-mail/gitlabtomail.py b/gitlab/gitlab-to-mail/gitlabtomail.py
index 45f829f..6aa16be 100755
--- a/gitlab/gitlab-to-mail/gitlabtomail.py
+++ b/gitlab/gitlab-to-mail/gitlabtomail.py
@@ -349,9 +349,12 @@ def process_commented_on(event):
         log("comment was originally from the mailing list.")
         return
 
+    patches = split_mbox_into_messages(fetch_mr_patches(mr_iid))
+    nr_patches = len(patches)
+
     mail = email.message.Message()
     mail['From'] = email.utils.formataddr((author, settings.BRIDGE_FROM_EMAIL))
-    mail['Subject'] = f"Re: {BRIDGE_TAG_FULL}MR{mr_iid}v{mr_version} - {title}"
+    mail['Subject'] = "Re: " + cover_subject(mr_version, nr_patches, mr_iid, title)
     mail['Message-ID'] = create_message_id(mr_iid, mr_version, note_id=note_id)
     mail['In-Reply-To'] = create_message_id(mr_iid, mr_version)
     mail['References'] = create_reference(mr_id, gitlab_hostname)
@@ -377,9 +380,12 @@ def process_closed(event):
     action_name = event['action_name']
     event_id = event['id']
 
+    patches = split_mbox_into_messages(fetch_mr_patches(mr_iid))
+    nr_patches = len(patches)
+
     mail = email.message.Message()
     mail['From'] = email.utils.formataddr((author, settings.BRIDGE_FROM_EMAIL))
-    mail['Subject'] = f"{BRIDGE_TAG_FULL}MR{mr_iid}v{mr_version} - {title} - {action_name}"
+    mail['Subject'] = "Re: " + cover_subject(mr_version, nr_patches, mr_iid, title) + f" - {action_name}"
     mail['Message-ID'] = create_message_id(mr_iid, mr_version, event_id=event_id)
     mail['In-Reply-To'] = create_message_id(mr_iid, mr_version)
     mail['References'] = create_reference(mr_id, gitlab_hostname)
@@ -518,6 +524,12 @@ def get_changes(iid, version, versionid, old_versionid, mr):
     return "\n" + version_string + changes
 
 
+def cover_subject(mr_version, nr_patches, mr_iid, title):
+    vstring = ""
+    if mr_version > 1:
+        vstring = f" v{mr_version}"
+    return f"[PATCH{BRIDGE_TAG_INFIX}{vstring} 0/{nr_patches}] MR{mr_iid}: {title}"
+
 def create_cover(mr_id, mr_iid, mr_version, versions, nr_patches, mr):
     author_name = f"{mr['author']['name']} (@{mr['author']['username']})"
     title = mr['title']
@@ -525,10 +537,8 @@ def create_cover(mr_id, mr_iid, mr_version, versions, nr_patches, mr):
 
     mail = email.message.Message()
     mail['From'] = email.utils.formataddr((author_name, settings.BRIDGE_FROM_EMAIL))
-    vstring = ""
     changes = ""
     if mr_version > 1:
-        vstring = f" v{mr_version}"
         if len(versions) > 1:
             # The versions array seems to be most recent first, while mr_version
             #   is the positive version number.  TODO: this assumes that the
@@ -539,7 +549,7 @@ def create_cover(mr_id, mr_iid, mr_version, versions, nr_patches, mr):
             if changes is None:
                 return None
 
-    mail['Subject'] = f"[PATCH{BRIDGE_TAG_INFIX}{vstring} 0/{nr_patches}] MR{mr_iid}: {title}"
+    mail['Subject'] = cover_subject(mr_version, nr_patches, mr_iid, title)
     mail['Message-ID'] = create_message_id(mr_iid, mr_version)
     mail['References'] = create_reference(mr_id, gitlab_hostname)
 




More information about the wine-cvs mailing list