parameters: (body)
docstring: Grep for "BUG=xxxx" lines in the commit message and convert them to
    "(issue xxxx)".
docstring_summary: Grep for "BUG=xxxx" lines in the commit message and convert them to
    "(issue xxxx)".
docstring_tokens: Grep for BUG = xxxx lines in the commit message and convert them to ( issue xxxx ) .
function: def MakeChangeLogBugReference(body):
    """Grep for "BUG=xxxx" lines in the commit message and convert them to
    "(issue xxxx)".
    """
    crbugs = []
    v8bugs = []
  
    def AddIssues(text):
      ref = re.match(r"^BUG[ \t]*=[ \t]*(.+)$", text.strip())
      if not ref:
        return
      for bug in ref.group(1).split(","):
        bug = bug.strip()
        match = re.match(r"^v8:(\d+)$", bug)
        if match: v8bugs.append(int(match.group(1)))
        else:
          match = re.match(r"^(?:chromium:)?(\d+)$", bug)
          if match: crbugs.append(int(match.group(1)))
  
    # Add issues to crbugs and v8bugs.
    map(AddIssues, body.splitlines())
  
    # Filter duplicates, sort, stringify.
    crbugs = map(str, sorted(set(crbugs)))
    v8bugs = map(str, sorted(set(v8bugs)))
  
    bug_groups = []
    def FormatIssues(prefix, bugs):
      if len(bugs) > 0:
        plural = "s" if len(bugs) > 1 else ""
        bug_groups.append("%sissue%s %s" % (prefix, plural, ", ".join(bugs)))
  
    FormatIssues("", v8bugs)
    FormatIssues("Chromium ", crbugs)
  
    if len(bug_groups) > 0:
      return "(%s)" % ", ".join(bug_groups)
    else:
      return ""
function_tokens: def MakeChangeLogBugReference ( body ) : crbugs = [ ] v8bugs = [ ] def AddIssues ( text ) : ref = re . match ( r"^BUG[ \t]*=[ \t]*(.+)$" , text . strip ( ) ) if not ref : return for bug in ref . group ( 1 ) . split ( "," ) : bug = bug . strip ( ) match = re . match ( r"^v8:(\d+)$" , bug ) if match : v8bugs . append ( int ( match . group ( 1 ) ) ) else : match = re . match ( r"^(?:chromium:)?(\d+)$" , bug ) if match : crbugs . append ( int ( match . group ( 1 ) ) ) # Add issues to crbugs and v8bugs. map ( AddIssues , body . splitlines ( ) ) # Filter duplicates, sort, stringify. crbugs = map ( str , sorted ( set ( crbugs ) ) ) v8bugs = map ( str , sorted ( set ( v8bugs ) ) ) bug_groups = [ ] def FormatIssues ( prefix , bugs ) : if len ( bugs ) > 0 : plural = "s" if len ( bugs ) > 1 else "" bug_groups . append ( "%sissue%s %s" % ( prefix , plural , ", " . join ( bugs ) ) ) FormatIssues ( "" , v8bugs ) FormatIssues ( "Chromium " , crbugs ) if len ( bug_groups ) > 0 : return "(%s)" % ", " . join ( bug_groups ) else : return ""