@@ -200,6 +200,70 @@ see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .
new_ver, base_ver, sender.split()[0] )
# end of def message_text
+ # function to generate the announcement email (cover letter)
+ #
+ def generate_cover_letter(self, editor, sender, base_ver, main_ver):
+
+ new_ver = self.cfg['new_version']
+ old_head = self.cfg['previous_release']
+
+ ann_ver = "%s.z" % base_ver
+
+ # Get the number of patches, diffstat and shortlog from
+ # previous release
+ status, result = run_command("git log --no-merges "
+ "--format=%%h %s.. | wc -l" %
+ (old_head), self.debug_run)
+ if status != 0:
+ raise GitError("\n".join(result))
+ patch_cnt = result[0]
+ status, diffstat = getstatusoutput("git diff --stat %s.." %
+ (old_head))
+ if status != 0:
+ raise GitError(diffstat)
+ status, shortlog = getstatusoutput("git shortlog %s.." %
+ (old_head))
+ if status != 0:
+ raise GitError(shortlog)
+
+ mailbody = "# This is the cover letter message for the patch"
+ mailbody += " series, that will be\n# sent as the start for"
+ mailbody += " the review thread. Review this and edit+save"
+ mailbody += " if\n# necessary. Lines beginning with '#' will"
+ mailbody += " not be included in the sent\n# email.\n#\n"
+ mailbody += "From: " + sender + '\n'
+ for entry in self.tolist:
+ mailbody += "To: " + entry + '\n'
+ mailbody += ("Subject: [ %s extended stable ] Linux %s stable review"
+ % (ann_ver, new_ver) + "\n")
+ mailbody += "X-Extended-Stable: %s\n" % (main_ver)
+ mailbody += self.message_text(base_ver, new_ver, patch_cnt, sender)
+ mailbody += diffstat + '\n\n'
+ mailbody += shortlog
+ tf = NamedTemporaryFile(prefix="pmail-")
+ tf.write(mailbody)
+ tf.flush()
+ try:
+ call([editor, tf.name])
+ except:
+ print("%s not found to edit cover letter for the patch series."
+ % editor)
+ print("Please install an editor, if your system doesn't have")
+ print(" /usr/bin/editor setup as alternatives, you can set the")
+ print(" NSR_EDITOR environment variable pointing to the editor")
+ print(" executable (eg. vim, nano, etc.)")
+ tf.close()
+ return
+ tfe = NamedTemporaryFile(prefix="mail-")
+ tf.seek(0)
+ for line in tf:
+ if line.startswith("#"):
+ continue
+ tfe.write(line)
+ tfe.flush()
+ tf.close()
+ return tfe;
+
# function to add headers to the patches
#
def modify_patch(self, patch, version, basever):
@@ -331,28 +395,10 @@ see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .
else:
base_ver = "%s.%s.y" % (kver[0], kver[1])
main_ver = "%s.%s" % (kver[0], kver[1])
- ann_ver = "%s.z" % base_ver
old_head = self.cfg['previous_release']
new_ver = self.cfg['new_version']
- # Get the number of patches, diffstat and shortlog from
- # previous release
- status, result = run_command("git log --no-merges "
- "--format=%%h %s.. | wc -l" %
- (old_head), self.debug_run)
- if status != 0:
- raise GitError("\n".join(result))
- patch_cnt = result[0]
- status, diffstat = getstatusoutput("git diff --stat %s.." %
- (old_head))
- if status != 0:
- raise GitError(diffstat)
- status, shortlog = getstatusoutput("git shortlog %s.." %
- (old_head))
- if status != 0:
- raise GitError(shortlog)
-
# Create emails and send them
tmpdir = mkdtemp()
status, result = run_command("git format-patch -o %s %s.." %
@@ -363,43 +409,12 @@ see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .
patches = listdir(tmpdir)
for patch in patches:
self.modify_patch(tmpdir + "/" + patch, new_ver, main_ver)
- mailbody = "# This is the cover letter message for the patch"
- mailbody += " series, that will be\n# sent as the start for"
- mailbody += " the review thread. Review this and edit+save"
- mailbody += " if\n# necessary. Lines beginning with '#' will"
- mailbody += " not be included in the sent\n# email.\n#\n"
- mailbody += "From: " + sender + '\n'
- for entry in self.tolist:
- mailbody += "To: " + entry + '\n'
- mailbody += ("Subject: [ %s extended stable ] Linux %s stable review"
- % (ann_ver, new_ver) + "\n")
- mailbody += "X-Extended-Stable: %s\n" % (main_ver)
- mailbody += self.message_text(base_ver, new_ver, patch_cnt, sender)
- mailbody += diffstat + '\n\n'
- mailbody += shortlog
- tf = NamedTemporaryFile(prefix="pmail-")
- tf.write(mailbody)
- tf.flush()
- try:
- call([editor, tf.name])
- except:
- print("%s not found to edit cover letter for the patch series."
- % editor)
- print("Please install an editor, if your system doesn't have")
- print(" /usr/bin/editor setup as alternatives, you can set the")
- print(" NSR_EDITOR environment variable pointing to the editor")
- print(" executable (eg. vim, nano, etc.)")
- tf.close()
+
+ tfe = self.generate_cover_letter(editor, sender, base_ver, main_ver)
+ if not tfe:
rmtree(tmpdir)
return
- tfe = NamedTemporaryFile(prefix="mail-")
- tf.seek(0)
- for line in tf:
- if line.startswith("#"):
- continue
- tfe.write(line)
- tfe.flush()
- tf.close()
+
cmd = "git send-email --no-chain-reply-to --thread "
cmd += "--from \"" + sender + "\""
for line in self.tolist:
Code re-factor; no functional change. Signed-off-by: Kamal Mostafa <kamal@canonical.com> --- stable/notify-stable-review | 121 +++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 53 deletions(-)