Bug 1363048 - Add list of relevant bugs to release-drivers email r=rail
authorConnor Sheehan <csheehan@mozilla.com>
Fri, 19 May 2017 10:22:59 -0400
changeset 7539 dbcf7482a150b9100201c1ead1d522a07d2d2e87
parent 7538 ce7b1ba76090b6ca559a60ab58102a05476f3b9a
child 7540 344abce0def51bbc44c65eb99020c43b5cdc3c3f
push id5608
push userraliiev@mozilla.com
push dateFri, 19 May 2017 14:23:06 +0000
reviewersrail
bugs1363048
Bug 1363048 - Add list of relevant bugs to release-drivers email r=rail
lib/python/kickoff/buglist_creator.py
--- a/lib/python/kickoff/buglist_creator.py
+++ b/lib/python/kickoff/buglist_creator.py
@@ -1,21 +1,23 @@
 import logging
 import re
 import requests
 from operator import itemgetter
 from pkg_resources import parse_version
 from simplejson import JSONDecodeError
 
+BUGLIST_PREFIX = 'Bugs since previous changeset: '
 BACKOUT_REGEX = r'back(\s?)out|backed out|backing out'
+BACKOUT_PREFIX = 'Backouts since previous changeset: '
 BUGZILLA_BUGLIST_TEMPLATE = 'https://bugzilla.mozilla.org/buglist.cgi?bug_id={bugs}'
 BUG_NUMBER_REGEX = r'bug \d+'
 CHANGELOG_TO_FROM_STRING = '{product}_{version}_RELEASE'
 CHANGESET_URL_TEMPLATE = 'https://hg.mozilla.org/{release_branch}/{logtype}?fromchange={from_version}&tochange={to_version}&full=1'
-FULL_CHANGESET_PREFIX = 'Full Mercurial changeset: '
+FULL_CHANGESET_PREFIX = 'Full Mercurial changelog: '
 LIST_DESCRIPTION_TEMPLATE = 'Comparing Mercurial tag {from_version} to {to_version}:'
 MAX_BUGS_IN_BUGLIST = 250
 MERCURIAL_TAGS_URL_TEMPLATE = 'https://hg.mozilla.org/{release_branch}/json-tags'
 NO_BUGS = ''  # Return this when bug list can't be created
 URL_SHORTENER_TEMPLATE = 'https://bugzilla.mozilla.org/rest/bitly/shorten?url={url}'
 
 log = logging.getLogger(__name__)
 
@@ -104,18 +106,17 @@ def is_excluded_change(changeset):
 
 def is_backout_bug(changeset_description_lowercase):
     return re.search(BACKOUT_REGEX, changeset_description_lowercase)
 
 
 def create_short_url_with_prefix(buglist, backout_buglist):
     # Create link if there are bugs, else empty string
     urls = []
-    for set_of_bugs, prefix in ((buglist, 'Bugs since previous changeset: ',),
-                               (backout_buglist, 'Backouts since previous changeset: ',)):
+    for set_of_bugs, prefix in [(buglist, BUGLIST_PREFIX), (backout_buglist, BACKOUT_PREFIX)]:
         if set_of_bugs and len(set_of_bugs) < MAX_BUGS_IN_BUGLIST:
             try:
                 long_bugzilla_link = BUGZILLA_BUGLIST_TEMPLATE.format(bugs='%2C'.join(set_of_bugs))
                 url = requests.get(URL_SHORTENER_TEMPLATE.format(url=long_bugzilla_link)).json()['url']
                 url = prefix + url + '\n'
 
             except (KeyError, JSONDecodeError,):
                 # If the Bugzilla link fails despite limiting the number of bugs, don't make the url and continue