Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Pass original subject of the email to reply to
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
veruu committed May 14, 2018
1 parent 4a6eae4 commit ed7a37a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
2 changes: 2 additions & 0 deletions sktm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 7 additions & 1 deletion sktm/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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)

Expand Down
38 changes: 29 additions & 9 deletions sktm/patchwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ed7a37a

Please sign in to comment.