From d4d83afc82e2c5e636f3f796cc70a79d2d6e2ac0 Mon Sep 17 00:00:00 2001 From: Steven Deaton Date: Mon, 10 Jun 2013 11:04:16 +1000 Subject: [PATCH] autogenerate doc bug reports based on DocImpact tag DocImpact has worked well for communicating new features and code changes that impact documentation to the doc team. However, the bulk of the emails received were essentially just turned into bug reports. This change allows the automated creation of those bug reports. The code searches for potential duplicate bugs before creating a bug to avoid creating multiple bugs per review. Note that this is originally the page from https://review.openstack.org/#/c/30718/ However, I'm drowning in DocImpact emails and wanted to move things along while the original author (Steven Deaton) is on holiday. There is potential future work here to: 1) alter the text on bug update 2) close bugs associated with abandoned patch sets 3) mark patch-merged bugs as 'confirmed' though, as one of the main benefactors from this code, I am quite happy to put this forward without these extras initially if it is acceptable to our awesome infra team :) patchset 2 updates documentation strings thanks to excellent feedback :) fixes bug 1184845 Change-Id: Ia3a8a203314c4e527855df1623491f96da06b882 Reviewed-on: https://review.openstack.org/32348 Reviewed-by: Jeremy Stanley Approved: Clark Boylan Reviewed-by: Clark Boylan Tested-by: Jenkins --- jeepyb/cmd/notify_impact.py | 54 +++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/jeepyb/cmd/notify_impact.py b/jeepyb/cmd/notify_impact.py index fd14173..6abcdfa 100644 --- a/jeepyb/cmd/notify_impact.py +++ b/jeepyb/cmd/notify_impact.py @@ -18,11 +18,14 @@ # bugs status. import argparse +import os import re import subprocess import smtplib from email.mime.text import MIMEText +from launchpadlib.launchpad import Launchpad +from launchpadlib.uris import LPNET_SERVICE_ROOT BASE_DIR = '/home/gerrit2/review_site' EMAIL_TEMPLATE = """ @@ -33,11 +36,58 @@ Hi, I'd like you to take a look at this patch for potential Log: %s """ +DOC_EMAIL_TEMPLATE = """ +Hi, I'd like you to take a look at this patch for potential +%s. +%s + +Log: +%s +Automatically generated bug (please review): +%s +""" +GERRIT_CACHE_DIR = os.path.expanduser( + os.environ.get('GERRIT_CACHE_DIR', + '~/.launchpadlib/cache')) +GERRIT_CREDENTIALS = os.path.expanduser( + os.environ.get('GERRIT_CREDENTIALS', + '~/.launchpadlib/creds')) def process_impact(git_log, args): - """Notify mail list of impact""" - email_content = EMAIL_TEMPLATE % (args.impact, args.change_url, git_log) + """ + If the 'DocImpact' flag is present, create a new documentation bug in + the openstack-manuals launchpad project based on the git_log, then + (and for non-documentation impacts) notify the mailing list of impact + """ + if args.dest_address.lower == 'docimpact': + launchpad = Launchpad.login_with('Gerrit User Sync', + LPNET_SERVICE_ROOT, + GERRIT_CACHE_DIR, + credentials_file=GERRIT_CREDENTIALS, + version='devel') + lines_in_log = git_log.split("\n") + bug_title = lines_in_log[4] + bug_descr = git_log + project_name = 'openstack-manuals' + project = launchpad.projects[project_name] + + # check for existing bugs by searching for the title, to avoid + # creating multiple bugs per review + potential_dupes = project.searchTasks(search_text=bug_title) + + if len(potential_dupes) == 0: + buginfo = launchpad.bugs.createBug(target=project, + title=bug_title, + description=bug_descr) + buglink = buginfo.web_link + email_content = DOC_EMAIL_TEMPLATE % (args.impact, + args.change_url, + git_log, buglink) + else: + email_content = EMAIL_TEMPLATE % (args.impact, + args.change_url, git_log) + msg = MIMEText(email_content) msg['Subject'] = '[%s] %s review request change %s' % \ (args.project, args.impact, args.change)