tools/android/modularization/owners/getowners.py
def _fetch_git_data(chromium_root: str,
                    requested_path: owners_data.RequestedPath
                    ) -> owners_data.GitData:
  '''Fetches git data for a given directory for the last 182 days.

  Includes # of commits, reverts, relands, authors, and reviewers.
  '''

  line_delimiter = '\ncommit '
  author_search = r'^Author: (.*) <(.*)>'
  date_search = r'Date:   (.*)'
  reviewer_search = r'^    Reviewed-by: (.*) <(.*)>'
  revert_token = r'^    (\[?)Revert(\]?) \"'
  reland_token = r'^    (\[?)Reland(\]?) \"'

  ignored_authors = ('autoroll', 'roller')

  git_log = owners_git.get_log(chromium_root, requested_path.path, 182)
  git_data = owners_data.GitData()

  for commit_msg in git_log.split(line_delimiter):
    author_re = re.search(author_search, commit_msg,
                          re.IGNORECASE | re.MULTILINE)
    if author_re:
      author = author_re.group(2)
      if any(ignored in author for ignored in ignored_authors):
        continue  # ignore flagged authors
      git_data.authors[author] += 1

    reviewer_re = re.findall(reviewer_search, commit_msg,
                             re.IGNORECASE | re.MULTILINE)
    for _, reviewer in reviewer_re:
      git_data.reviewers[reviewer] += 1

    date_re = re.search(date_search, commit_msg, re.IGNORECASE | re.MULTILINE)
    if date_re and not git_data.latest_cl_date:
      d = date_re.group(1).strip().split(' ')[:-1]  # Minus tz offset.
      dobj = datetime.datetime.strptime(' '.join(d), '%a %b %d %H:%M:%S %Y')
      git_data.latest_cl_date = int(dobj.timestamp())

    git_data.cls += 1

    for i, line in enumerate(commit_msg.split('\n')):
      if i == 4:
        if re.search(revert_token, line, re.IGNORECASE | re.MULTILINE):
          git_data.reverted_cls += 1
        if re.search(reland_token, line, re.IGNORECASE | re.MULTILINE):
          git_data.relanded_cls += 1
        break

  git_data.lines_of_code = owners_git.get_total_lines_of_code(
      chromium_root, requested_path.path)
  git_data.number_of_files = owners_git.get_total_files(chromium_root,
                                                        requested_path.path)
  git_data.git_head = owners_git.get_head_hash(chromium_root)
  git_data.git_head_time = owners_git.get_last_commit_date(chromium_root)

  return git_data
Fetches git data for a given directory for the last 182 days.

  Includes # of commits, reverts, relands, authors, and reviewers.
  
Fetches git data for a given directory for the last 182 days.
Includes # of commits, reverts, relands, authors, and reviewers.
Fetches git data for a given directory for the last 182 days . Includes # of commits reverts relands authors and reviewers .
def _fetch_git_data(chromium_root: str,
                    requested_path: owners_data.RequestedPath
                    ) -> owners_data.GitData:
  line_delimiter = '\ncommit '
  author_search = r'^Author: (.*) <(.*)>'
  date_search = r'Date:   (.*)'
  reviewer_search = r'^    Reviewed-by: (.*) <(.*)>'
  revert_token = r'^    (\[?)Revert(\]?) \"'
  reland_token = r'^    (\[?)Reland(\]?) \"'
  ignored_authors = ('autoroll', 'roller')
  git_log = owners_git.get_log(chromium_root, requested_path.path, 182)
  git_data = owners_data.GitData()
  for commit_msg in git_log.split(line_delimiter):
    author_re = re.search(author_search, commit_msg,
                          re.IGNORECASE | re.MULTILINE)
    if author_re:
      author = author_re.group(2)
      if any(ignored in author for ignored in ignored_authors):
        continue  
      git_data.authors[author] += 1
    reviewer_re = re.findall(reviewer_search, commit_msg,
                             re.IGNORECASE | re.MULTILINE)
    for _, reviewer in reviewer_re:
      git_data.reviewers[reviewer] += 1
    date_re = re.search(date_search, commit_msg, re.IGNORECASE | re.MULTILINE)
    if date_re and not git_data.latest_cl_date:
      d = date_re.group(1).strip().split(' ')[:-1]  
      dobj = datetime.datetime.strptime(' '.join(d), '%a %b %d %H:%M:%S %Y')
      git_data.latest_cl_date = int(dobj.timestamp())
    git_data.cls += 1
    for i, line in enumerate(commit_msg.split('\n')):
      if i == 4:
        if re.search(revert_token, line, re.IGNORECASE | re.MULTILINE):
          git_data.reverted_cls += 1
        if re.search(reland_token, line, re.IGNORECASE | re.MULTILINE):
          git_data.relanded_cls += 1
        break
  git_data.lines_of_code = owners_git.get_total_lines_of_code(
      chromium_root, requested_path.path)
  git_data.number_of_files = owners_git.get_total_files(chromium_root,
                                                        requested_path.path)
  git_data.git_head = owners_git.get_head_hash(chromium_root)
  git_data.git_head_time = owners_git.get_last_commit_date(chromium_root)
  return git_data
def _fetch_git_data ( chromium_root : str , requested_path : owners_data . RequestedPath ) -> owners_data . GitData : line_delimiter = '\ncommit ' author_search = r'^Author: (.*) <(.*)>' date_search = r'Date:   (.*)' reviewer_search = r'^    Reviewed-by: (.*) <(.*)>' revert_token = r'^    (\[?)Revert(\]?) \"' reland_token = r'^    (\[?)Reland(\]?) \"' ignored_authors = ( 'autoroll' , 'roller' ) git_log = owners_git . get_log ( chromium_root , requested_path . path , 182 ) git_data = owners_data . GitData ( ) for commit_msg in git_log . split ( line_delimiter ) : author_re = re . search ( author_search , commit_msg , re . IGNORECASE | re . MULTILINE ) if author_re : author = author_re . group ( 2 ) if any ( ignored in author for ignored in ignored_authors ) : continue git_data . authors [ author ] += 1 reviewer_re = re . findall ( reviewer_search , commit_msg , re . IGNORECASE | re . MULTILINE ) for _ , reviewer in reviewer_re : git_data . reviewers [ reviewer ] += 1 date_re = re . search ( date_search , commit_msg , re . IGNORECASE | re . MULTILINE ) if date_re and not git_data . latest_cl_date : d = date_re . group ( 1 ) . strip ( ) . split ( ' ' ) [ : - 1 ] dobj = datetime . datetime . strptime ( ' ' . join ( d ) , '%a %b %d %H:%M:%S %Y' ) git_data . latest_cl_date = int ( dobj . timestamp ( ) ) git_data . cls += 1 for i , line in enumerate ( commit_msg . split ( '\n' ) ) : if i == 4 : if re . search ( revert_token , line , re . IGNORECASE | re . MULTILINE ) : git_data . reverted_cls += 1 if re . search ( reland_token , line , re . IGNORECASE | re . MULTILINE ) : git_data . relanded_cls += 1 break git_data . lines_of_code = owners_git . get_total_lines_of_code ( chromium_root , requested_path . path ) git_data . number_of_files = owners_git . get_total_files ( chromium_root , requested_path . path ) git_data . git_head = owners_git . get_head_hash ( chromium_root ) git_data . git_head_time = owners_git . get_last_commit_date ( chromium_root ) return git_data
Fetches git data for a given directory for the last 182 days.
Fetches git data for a given directory for the last 182 days .
'''Fetches git data for a given directory for the last 182 days.

  Includes # of commits, reverts, relands, authors, and reviewers.
  ''' # ignore flagged authors # Minus tz offset.
chromium_root
str
requested_path
owners_data.RequestedPath