From ed7a37a35144cb4fde6ec0f3bbc347a4d4fea3e3 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Wed, 9 May 2018 16:57:02 +0200 Subject: [PATCH] Pass original subject of the email to reply to Retrieve subject from the patch we are replying to and pass it to Jenkins build. It can then be extracted from parameters and passed to skt's email reporter. Fixes #42 Signed-off-by: Veronika Kabatova --- sktm/__init__.py | 2 ++ sktm/jenkins.py | 8 +++++++- sktm/patchwork.py | 38 +++++++++++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/sktm/__init__.py b/sktm/__init__.py index 042dd4c5..c9ffb924 100644 --- a/sktm/__init__.py +++ b/sktm/__init__.py @@ -212,11 +212,13 @@ def check_patchwork(self): ref=stablecommit, baseconfig=self.cfgurl, message_id=patchset.message_id, + subject=patchset.subject, emails=patchset.email_addr_set, patchwork=patchset.patch_url_list, makeopts=self.makeopts), cpw)) logging.info("submitted message ID: %s", patchset.message_id) + logging.info("submitted subject: %s", patchset.subject) logging.info("submitted emails: %s", patchset.email_addr_set) logging.info("submitted patchset: %s", patchset.patch_url_list) diff --git a/sktm/jenkins.py b/sktm/jenkins.py index 156beaf6..0096b448 100644 --- a/sktm/jenkins.py +++ b/sktm/jenkins.py @@ -171,7 +171,8 @@ def get_result(self, jobname, buildid): # FIXME Clarify/fix argument names def build(self, jobname, baserepo=None, ref=None, baseconfig=None, - message_id=None, emails=set(), patchwork=[], makeopts=None): + message_id=None, subject=None, emails=set(), patchwork=[], + makeopts=None): """ Submit a build of a patchset. @@ -182,6 +183,8 @@ def build(self, jobname, baserepo=None, ref=None, baseconfig=None, baseconfig: Kernel configuration URL. message_id: Value of the "Message-Id" header of the e-mail message representing the patchset, or None if unknown. + subject: Subject of the message representing the patchset, or + None if unknown. emails: Set of e-mail addresses involved with the patchset to send notifications to. patchwork: List of URLs pointing to patches to apply. @@ -204,6 +207,9 @@ def build(self, jobname, baserepo=None, ref=None, baseconfig=None, if message_id: params["message_id"] = message_id + if subject: + params["subject"] = subject + if emails: params["emails"] = ",".join(emails) diff --git a/sktm/patchwork.py b/sktm/patchwork.py index 32d14ecf..33388214 100644 --- a/sktm/patchwork.py +++ b/sktm/patchwork.py @@ -29,13 +29,14 @@ class PatchsetSummary(object): """A patchset summary""" - def __init__(self, message_id, email_addr_set, patch_url_list): + def __init__(self, message_id, subject, email_addr_set, patch_url_list): """ Initialize a patchset summary. Args: message_id: Value of the "Message-Id" header of the e-mail message representing the patchset. + subject: Subject of the message representing the patchset. email_addr_set: A set of e-mail addresses involved with the patchset. patch_url_list: A list of URLs pointing to Patchwork patch @@ -44,6 +45,8 @@ def __init__(self, message_id, email_addr_set, patch_url_list): """ # Message-Id of the message representing the patchset self.message_id = message_id + # Subject of the message representing the patchset + self.subject = subject # A set of e-mail addresses involved with the patchset self.email_addr_set = email_addr_set # A list of URLs pointing to Patchwork patch objects comprising @@ -306,6 +309,7 @@ def get_series_from_url(self, url): for series in sdata: message_id = None + subject = None all_emails = set() plist = list() @@ -326,11 +330,14 @@ def get_series_from_url(self, url): logging.info("patch [%d] %s", patch.get("id"), patch.get("name")) plist.append(self.patchurl(patch)) - message_id = self.get_header_value(patch.get("id"), - 'Message-ID') + message_id, subject = self.get_header_value(patch.get("id"), + 'Message-ID', + 'Subject') emails = self.get_emails(patch.get("id")) logging.debug("patch [%d] message_id: %s", patch.get("id"), message_id) + logging.debug("patch [%d] subject: %s", patch.get("id"), + subject) logging.debug("patch [%d] emails: %s", patch.get("id"), emails) all_emails = all_emails.union(emails) @@ -339,10 +346,14 @@ def get_series_from_url(self, url): if plist: logging.debug("series [%d] message_id: %s", series.get("id"), message_id) + logging.debug("series [%d] subject: %s", series.get("id"), + subject) logging.debug("series [%d] emails: %s", series.get("id"), all_emails) - patchsets.append( - PatchsetSummary(message_id, all_emails, plist)) + patchsets.append(PatchsetSummary(message_id, + subject, + all_emails, + plist)) link = r.headers.get("Link") if link is not None: @@ -973,28 +984,37 @@ def parse_patch(self, patch): logging.info("patchset: %s", seriesid) message_id = None + subject = None all_emails = set() patchset = list() # For each patch position in series in order for cpatch in sorted(self.series[seriesid].keys()): patch = self.series[seriesid].get(cpatch) pid = patch.get("id") - message_id = self.get_header_value(pid, 'Message-ID') + message_id, subject = self.get_header_value(pid, + 'Message-ID', + 'Subject') emails = self.get_emails(pid) self.log_patch(pid, patch.get("name"), message_id, emails) all_emails = all_emails.union(emails) patchset.append(self.patchurl(patch)) logging.info("message_id: %s", message_id) + logging.info("subject: %s", subject) logging.info("emails: %s", all_emails) logging.info("---") - result = PatchsetSummary(message_id, all_emails, patchset) + result = PatchsetSummary(message_id, + subject, + all_emails, + patchset) # Else, it's a single patch else: - message_id = self.get_header_value(pid, 'Message-ID') + message_id, subject = self.get_header_value(pid, + 'Message-ID', + 'Subject') emails = self.get_emails(pid) self.log_patch(pid, pname, message_id, emails) - result = PatchsetSummary(message_id, emails, + result = PatchsetSummary(message_id, subject, emails, [self.patchurl(patch)]) if pid > self.lastpatch: