X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tools%2Fdistchanges%2Fchanges.py;h=297e4f3adcf2aa49bd2927ef1e9755d8b78b6432;hb=c6740c77a4706a11379d2b074fc5d380a610d9af;hp=608f3c520dd3af4334415879817c0fc83f088808;hpb=0bd0fb4c72b986ef92b02354bfb9484a5d05e37c;p=integration%2Ftest.git diff --git a/tools/distchanges/changes.py b/tools/distchanges/changes.py index 608f3c520d..297e4f3adc 100644 --- a/tools/distchanges/changes.py +++ b/tools/distchanges/changes.py @@ -101,7 +101,7 @@ class Changes(object): self.verbose = verbose self.projects = {} self.set_log_level(verbose) - self.regex_changeid = re.compile(r'\bI([a-f0-9]{40})\b|\bI([a-f0-9]{8})\b') + self.regex_changeid = re.compile(r'(Change-Id.*: (\bI[a-f0-9]{40})\b|\bI([a-f0-9]{8})\b)') # self.regex_shortmsg = re.compile(r'"([^"]*)"|(git.commit.message.short=(.*))') self.regex_shortmsg1 = re.compile(r'(git.commit.message.short=.*"([^"]*)")') self.regex_shortmsg2 = re.compile(r'(git.commit.message.short=(.*))') @@ -135,6 +135,9 @@ class Changes(object): gerrit["subject"].encode('ascii', 'replace') if "subject" in gerrit else "none")) def pretty_print_projects(self, projects): + print("========================================") + print("distchanges") + print("========================================") if isinstance(projects, dict): for project_name, values in sorted(projects.items()): if "includes" in values: @@ -252,26 +255,26 @@ class Changes(object): logger.info("trying Change-Id from git.properties in %s", project) # match a 40 or 8 char Change-Id hash. both start with I changeid = self.regex_changeid.search(pfile) - if changeid: - logger.info("trying Change-Id from git.properties as merged in %s: %s", project, changeid.group()) + if changeid and changeid.group(2): + logger.info("trying Change-Id from git.properties as merged in %s: %s", project, changeid.group(2)) - gerrits = self.gerritquery.get_gerrits(project, changeid.group(), 1, None, status="merged") + gerrits = self.gerritquery.get_gerrits(project, changeid.group(2), 1, None, status="merged") if gerrits: logger.info("found Change-Id from git.properties as merged in %s", project) - return ChangeId(changeid.group(), True) + return ChangeId(changeid.group(2), True) # Maybe this is a patch that has not merged yet logger.info("did not find Change-Id from git.properties as merged in %s, trying as unmerged: %s", - project, changeid.group()) + project, changeid.group(2)) - gerrits = self.gerritquery.get_gerrits(project, changeid.group(), 1, None, status=None, comments=True) + gerrits = self.gerritquery.get_gerrits(project, changeid.group(2), 1, None, status=None, comments=True) if gerrits: logger.info("found Change-Id from git.properties as unmerged in %s", project) return ChangeId(gerrits[0]["id"], False) logger.info("did not find Change-Id from git.properties in %s, trying commitid", project) - # match a 40 or 8 char Change-Id hash. both start with I + # match a git commit id commitid = self.regex_commitid.search(pfile) if commitid and commitid.group(2): logger.info("trying commitid from git.properties in %s: %s", project, commitid.group(2)) @@ -376,6 +379,43 @@ class Changes(object): logger.warn("Could not find a git.properties file for %s", project) return ChangeId(None, False) + def get_taglist(self): + """ + Read a taglist.log file into memory + + :return taglist: The taglist.log file read into memory + """ + tagfile = os.path.join(self.distro_path, "taglist.log") + taglist = None + # Ensure the file exists and then read it + if os.path.isfile(tagfile): + with open(tagfile, 'r') as fp: + taglist = fp.read() + return taglist + + def find_project_commit_changeid(self, taglist, project): + """ + Find a commit id for the given project + + :param str taglist: the taglist.log file read into memory + :param str project: The project to search + :return ChangeId: The Change-Id with a valid Change-Id or None if not found + """ + # break the regex up since {} is a valid regex element but we need it for the format project + re1 = r'({0} '.format(project) + re1 = re1 + r'(\b[a-f0-9]{40})\b|\b([a-f0-9]{8})\b' + r')' + commitid = re.search(re1, taglist) + if commitid and commitid.group(2): + logger.info("trying commitid from taglist.log in %s: %s", project, commitid.group(2)) + + gerrits = self.gerritquery.get_gerrits(project, commitid=commitid.group(2)) + if gerrits: + logger.info("found Change-Id from taglist.log as merged in %s", project) + return ChangeId(gerrits[0]["id"], True) + + logger.warn("did not find Change-Id from commitid from taglist.log in %s", project) + return ChangeId(None, False) + def init(self): self.gerritquery = gerritquery.GerritQuery(self.remote_url, self.branch, self.qlimit, self.verbose) self.set_projects(self.project_names) @@ -406,6 +446,19 @@ class Changes(object): if self.distro_url is not None: self.download_distro() + logger.info("Checking if this is an autorelease build by looking for taglist.log") + taglist = self.get_taglist() + if taglist is not None: + for project in sorted(self.projects): + logger.info("Processing %s using taglist.log", project) + changeid = self.find_project_commit_changeid(taglist, project) + if changeid.changeid: + self.projects[project]['commit'] = changeid.changeid + self.projects[project]["includes"] = \ + self.get_includes(project, changeid.changeid, msg=None, merged=changeid.merged) + return self.projects + + logger.info("This is not an autorelease build, continuing as integration distribution") for project in sorted(self.projects): logger.info("Processing %s", project) changeid = self.find_distro_changeid(project)