def RunStep(self): # Stringify: ["abcde", "12345"] -> "abcde, 12345" self["revision_list"] = ", ".join(self["full_revision_list"]) if not self["revision_list"]: # pragma: no cover self.Die("Revision list is empty.") msg_pieces = [] if len(self["full_revision_list"]) > 1: self["commit_title"] = "Merged: Squashed multiple commits." for commit_hash in self["full_revision_list"]: msg_pieces.append(self._create_commit_description(commit_hash)) else: commit_hash = self["full_revision_list"][0] full_description = self._create_commit_description( commit_hash).split("\n") #Truncate title because of code review tool title = full_description[0] if len(title) > 100: title = title[:96] + " ..." self["commit_title"] = title msg_pieces.append(full_description[1] + "\n\n") bugs = [] for commit_hash in self["full_revision_list"]: msg = self.GitLog(n=1, git_hash=commit_hash) for bug in re.findall(r"^[ \t]*BUG[ \t]*=[ \t]*(.*?)[ \t]*$", msg, re.M): bugs.extend(s.strip() for s in bug.split(",")) gerrit_bug = GetCommitMessageFooterMap(msg).get('Bug', '') bugs.extend(s.strip() for s in gerrit_bug.split(",")) bug_aggregate = ",".join( sorted(filter(lambda s: s and s != "none", set(bugs)))) if bug_aggregate: # TODO(machenbach): Use proper gerrit footer for bug after switch to # gerrit. Keep BUG= for now for backwards-compatibility. msg_pieces.append("BUG=%s\n" % bug_aggregate) msg_pieces.append("NOTRY=true\nNOPRESUBMIT=true\nNOTREECHECKS=true\n") self["new_commit_msg"] = "".join(msg_pieces)
def RunStep(self): # Stringify: ["abcde", "12345"] -> "abcde, 12345" self["revision_list"] = ", ".join(self["full_revision_list"]) if not self["revision_list"]: # pragma: no cover self.Die("Revision list is empty.") msg_pieces = [] if len(self["full_revision_list"]) > 1: self["commit_title"] = "Merged: Squashed multiple commits." for commit_hash in self["full_revision_list"]: msg_pieces.append(self._create_commit_description(commit_hash)) else: commit_hash = self["full_revision_list"][0] full_description = self._create_commit_description(commit_hash).split("\n") #Truncate title because of code review tool title = full_description[0] if len(title) > 100: title = title[:96] + " ..." self["commit_title"] = title msg_pieces.append(full_description[1] + "\n\n") bugs = [] for commit_hash in self["full_revision_list"]: msg = self.GitLog(n=1, git_hash=commit_hash) for bug in re.findall(r"^[ \t]*BUG[ \t]*=[ \t]*(.*?)[ \t]*$", msg, re.M): bugs.extend(s.strip() for s in bug.split(",")) gerrit_bug = GetCommitMessageFooterMap(msg).get('Bug', '') bugs.extend(s.strip() for s in gerrit_bug.split(",")) bug_aggregate = ",".join( sorted(filter(lambda s: s and s != "none", set(bugs)))) if bug_aggregate: # TODO(machenbach): Use proper gerrit footer for bug after switch to # gerrit. Keep BUG= for now for backwards-compatibility. msg_pieces.append("BUG=%s\nLOG=N\n" % bug_aggregate) msg_pieces.append("NOTRY=true\nNOPRESUBMIT=true\nNOTREECHECKS=true\n") self["new_commit_msg"] = "".join(msg_pieces)