# -*- coding: utf-8 -*- # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import logging import os import re from operator import itemgetter
import requests from mozilla_version.gecko import GeckoVersion from taskcluster import Notify, optionsFromEnvironment
BUGLIST_TEMPLATE = "* [Bugs since previous changeset]({url})\n"
BACKOUT_REGEX = re.compile(r"back(\s?)out|backed out|backing out", re.IGNORECASE)
BACKOUT_TEMPLATE = "* [Backouts since previous changeset]({url})\n"
BUGZILLA_BUGLIST_TEMPLATE = "https://bugzilla.mozilla.org/buglist.cgi?bug_id={bugs}"
BUG_NUMBER_REGEX = re.compile(r"bug \d+", re.IGNORECASE)
CHANGELOG_TO_FROM_STRING = "{product}_{version}_RELEASE"
CHANGESET_URL_TEMPLATE = ( "{repo}/{logtype}""?rev={to_version}+%25+{from_version}&revcount=1000"
)
FULL_CHANGESET_TEMPLATE = "* [Full Mercurial changelog]({url})\n"
LIST_DESCRIPTION_TEMPLATE = "Comparing Mercurial tag {from_version} to {to_version}:\n"
MAX_BUGS_IN_BUGLIST = 250
MERCURIAL_TAGS_URL_TEMPLATE = "{repo}/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__)
def create_bugs_url(product, current_version, current_revision, repo=None): """
Creates list of bugs and backout bugs for release-drivers email
:param release: dict -> containing information about release, from Ship-It
:return: str -> description of compared releases, with Bugzilla links
containing all bugs in changeset """ try: # Extract the important data, ignore if beta1 release if current_version.beta_number == 1: # If the version is beta 1, don't make any links return NO_BUGS
if repo isNone:
repo = get_repo_by_version(current_version) # Get the tag version, for display purposes
current_version_tag = tag_version(product, current_version)
# Get all Hg tags for this branch, determine the previous version
tag_url = MERCURIAL_TAGS_URL_TEMPLATE.format(repo=repo)
mercurial_tags_json = requests.get(tag_url).json()
previous_version_tag = get_previous_tag_version(
product, current_version, current_version_tag, mercurial_tags_json
)
# Get the changeset between these versions, parse for all unique bugs and backout bugs
resp = requests.get(
CHANGESET_URL_TEMPLATE.format(
repo=repo,
from_version=previous_version_tag,
to_version=current_revision,
logtype="json-log",
)
)
changeset_data = resp.json()
unique_bugs, unique_backout_bugs = get_bugs_in_changeset(changeset_data)
# Return a descriptive string with links if any relevant bugs are found if unique_bugs or unique_backout_bugs:
description = LIST_DESCRIPTION_TEMPLATE.format(
from_version=previous_version_tag, to_version=current_version_tag
)
if unique_bugs:
description += BUGLIST_TEMPLATE.format(
url=create_buglist_url(unique_bugs)
) if unique_backout_bugs:
description += BACKOUT_TEMPLATE.format(
url=create_buglist_url(unique_backout_bugs)
)
except Exception as err:
log.info(err) return NO_BUGS
def get_bugs_in_changeset(changeset_data):
unique_bugs, unique_backout_bugs = set(), set() for changeset in changeset_data["entries"]: if is_excluded_change(changeset): continue
def get_previous_tag_version(
product,
current_version,
current_version_tag,
mercurial_tags_json,
): """
Gets the previous hg version tag for the product and branch, given the current version tag """
def _invalid_tag_filter(tag): """Filters by product and removes incorrect major version + base, end releases"""
prod_major_version_re = r"^{product}_{major_version}".format(
product=product.upper(), major_version=current_version.major_number
)
return ( "BASE"notin tag and"END"notin tag and"RELEASE"in tag and re.match(prod_major_version_re, tag)
)
# Get rid of irrelevant tags, sort by date and extract the tag string
tags = {
(parse_tag_version(item["tag"]), item["tag"]) for item in mercurial_tags_json["tags"] if _invalid_tag_filter(item["tag"])
} # Add the current version to the list
tags.add((current_version, current_version_tag))
tags = sorted(tags, key=lambda tag: tag[0])
# Find where the current version is and go back one to get the previous version
next_version_index = list(map(itemgetter(0), tags)).index(current_version) - 1
# On r-d, we prefix the subject of the email in order to simplify filtering
subject_prefix = "" if product in {"fennec"}:
subject_prefix = "[mobile] " if product in {"firefox", "devedition"}:
subject_prefix = "[desktop] "
# use proxy if configured, otherwise local credentials from env vars if"TASKCLUSTER_PROXY_URL"in os.environ:
notify_options = {"rootUrl": os.environ["TASKCLUSTER_PROXY_URL"]} else:
notify_options = optionsFromEnvironment()
notify = Notify(notify_options) for address in addresses:
notify.email(
{ "address": address, "subject": subject, "content": content,
}
)
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.