Makes Impact bug creation generic, ceases doc spam
This patch moves the bug creation code to its own method, so that it can be used by other kinds of impacts. It also changes the notification logic for DocImpact, so that emails are now only sent if bug creation was not successful. This patch should have no effect on other kinds of impacts. patchset3 fixes use of sys and updated docstring patchset4 rebases to master Change-Id: I6b64beb6e8da45b166d17c9fad0347aa5370e689 Reviewed-on: https://review.openstack.org/34842 Approved: James E. Blair <corvus@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
@@ -36,16 +36,7 @@ Hi, I'd like you to take a look at this patch for potential
|
|||||||
Log:
|
Log:
|
||||||
%s
|
%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(
|
GERRIT_CACHE_DIR = os.path.expanduser(
|
||||||
os.environ.get('GERRIT_CACHE_DIR',
|
os.environ.get('GERRIT_CACHE_DIR',
|
||||||
'~/.launchpadlib/cache'))
|
'~/.launchpadlib/cache'))
|
||||||
@@ -54,39 +45,50 @@ GERRIT_CREDENTIALS = os.path.expanduser(
|
|||||||
'~/.launchpadlib/creds'))
|
'~/.launchpadlib/creds'))
|
||||||
|
|
||||||
|
|
||||||
def process_impact(git_log, args):
|
def create_bug(git_log, args, lp_project):
|
||||||
"""Process DocImpact flag.
|
"""Create a bug for a change.
|
||||||
|
|
||||||
If the 'DocImpact' flag is present, create a new documentation bug in
|
Create a launchpad bug in lp_project, titled with the first line of
|
||||||
the openstack-manuals launchpad project based on the git_log, then
|
the git commit message, with the content of the git_log prepended
|
||||||
(and for non-documentation impacts) notify the mailing list of impact
|
with the Gerrit review URL. Tag the bug with the name of the repository
|
||||||
|
it came from. Don't create a duplicate bug. Returns link to the bug.
|
||||||
"""
|
"""
|
||||||
if args.impact.lower() == 'docimpact':
|
|
||||||
lpconn = launchpad.Launchpad.login_with(
|
lpconn = launchpad.Launchpad.login_with(
|
||||||
'Gerrit User Sync',
|
'Gerrit User Sync',
|
||||||
uris.LPNET_SERVICE_ROOT,
|
uris.LPNET_SERVICE_ROOT,
|
||||||
GERRIT_CACHE_DIR,
|
GERRIT_CACHE_DIR,
|
||||||
credentials_file=GERRIT_CREDENTIALS,
|
credentials_file=GERRIT_CREDENTIALS,
|
||||||
version='devel')
|
version='devel')
|
||||||
|
|
||||||
lines_in_log = git_log.split("\n")
|
lines_in_log = git_log.split("\n")
|
||||||
bug_title = lines_in_log[4]
|
bug_title = lines_in_log[4]
|
||||||
bug_descr = args.change_url + '\n' + git_log
|
bug_descr = args.change_url + '\n' + git_log
|
||||||
project_name = 'openstack-manuals'
|
project = lpconn.projects[lp_project]
|
||||||
project = lpconn.projects[project_name]
|
|
||||||
|
|
||||||
# check for existing bugs by searching for the title, to avoid
|
# check for existing bugs by searching for the title, to avoid
|
||||||
# creating multiple bugs per review
|
# creating multiple bugs per review
|
||||||
potential_dupes = project.searchTasks(search_text=bug_title)
|
potential_dupes = project.searchTasks(search_text=bug_title)
|
||||||
|
|
||||||
if len(potential_dupes) == 0:
|
if len(potential_dupes) == 0:
|
||||||
buginfo = lpconn.bugs.createBug(
|
buginfo = lpconn.bugs.createBug(
|
||||||
target=project, title=bug_title,
|
target=project, title=bug_title,
|
||||||
description=bug_descr, tags=args.project.split('/')[1])
|
description=bug_descr, tags=args.project.split('/')[1])
|
||||||
buglink = buginfo.web_link
|
buglink = buginfo.web_link
|
||||||
email_content = DOC_EMAIL_TEMPLATE % (args.impact,
|
|
||||||
args.change_url,
|
return buglink
|
||||||
git_log, buglink)
|
|
||||||
else:
|
|
||||||
|
def process_impact(git_log, args):
|
||||||
|
"""Process DocImpact flag.
|
||||||
|
|
||||||
|
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,
|
||||||
|
unless a bug was created.
|
||||||
|
"""
|
||||||
|
if args.impact.lower() == 'docimpact':
|
||||||
|
buglink = create_bug(git_log, args, 'openstack-manuals')
|
||||||
|
if buglink is not None:
|
||||||
|
return
|
||||||
|
|
||||||
email_content = EMAIL_TEMPLATE % (args.impact,
|
email_content = EMAIL_TEMPLATE % (args.impact,
|
||||||
args.change_url, git_log)
|
args.change_url, git_log)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user