def test_get_tbr_no_lgtm(self):
   mock_cc = mock.MagicMock()
   mock_cc.fetchall.return_value = (
     ('https://codereview.chromium.org/993263002', 
      datetime.datetime(2015, 03, 11, 07, 11, 54),
      'Reland-Changes-in-infra-to-get-bot_setup-to-work-on-GCE-Windows',
      'vadimsh', '846e3e4cb43006dbe4f026881ba8ee06835f46b1'),
     ('https://codereview.chromium.org/1051013004', 
      datetime.datetime(2015, 04, 02, 01, 52, 29),
      'Also-let-cipd-support-i686-architecture', 'vadimsh',
      '8871159ca3f8d481e0e7aee7c1255fec9d5c92ee'),
     ('https://codereview.chromium.org/845263005', 
      datetime.datetime(2015, 01, 13, 00, 57, 32),
      'Revert-of-Revert-Revert-of-Add-internal.DEPS-to-bot_start.-patchset-5',
      'vadimsh', 'e263ef04abaffd4e59fd9b9009bb523179212467'),
   )
   expected_out = [
     ['https://codereview.chromium.org/1051013004', '2015-04-02 01:52:29',
      'Also let cipd support i686 architecture', 'vadimsh',
      '8871159ca3f8d481e0e7aee7c1255fec9d5c92ee'],
     ['https://codereview.chromium.org/993263002', '2015-03-11 07:11:54',
     'Reland Changes in infra to get bot_setup to work on GCE Windows',
     'vadimsh', '846e3e4cb43006dbe4f026881ba8ee06835f46b1'],
     ['https://codereview.chromium.org/845263005', '2015-01-13 00:57:32',
     'Revert of Revert Revert of Add internal.DEPS to bot_start. patchset 5',
     'vadimsh', 'e263ef04abaffd4e59fd9b9009bb523179212467'],
   ]
   out = code_review_parse.get_tbr_no_lgtm(mock_cc, 'tbr')
   self.assertItemsEqual(out, expected_out)
Beispiel #2
0
def get_commits_by_user(cc, gitiles_prefix, output_dirpath):
  # tbr_no_lgtm: review_url, request_timestamp, subject, people_email_address,
  # hash
  tbr_blame_dict = {}
  commits_tbred_to_user = code_review_parse.get_tbr_no_lgtm(cc, 'tbr')
  commits_authored_by_user = code_review_parse.get_tbr_no_lgtm(cc, 'author')
  for url, timestamp, subject, reviewer, git_hash in commits_tbred_to_user:
    tbr_blame_dict.setdefault(reviewer, {'tbr':[], 'author':[]})['tbr'].append(
        [subject, url, timestamp, git_hash, 'TBR'])
  for url, timestamp, subject, reviewer, git_hash in commits_authored_by_user:
    tbr_blame_dict.setdefault(reviewer, {'tbr':[],
                                         'author':[]})['author'].append(
        [subject, url, timestamp, git_hash, 'Author'])
  tbr_data = {
      "by_user" : tbr_blame_dict,
      "gitiles_prefix" : gitiles_prefix,
  }
  with open(os.path.join(output_dirpath, 'search_by_user.json'), 'wb') as f:
    f.write(json.dumps(tbr_data))
Beispiel #3
0
def get_commits_by_user(cc, gitiles_prefix, output_dirpath):
    # tbr_no_lgtm: review_url, request_timestamp, subject, people_email_address,
    # hash
    tbr_blame_dict = {}
    commits_tbred_to_user = code_review_parse.get_tbr_no_lgtm(cc, 'tbr')
    commits_authored_by_user = code_review_parse.get_tbr_no_lgtm(cc, 'author')
    for url, timestamp, subject, reviewer, git_hash in commits_tbred_to_user:
        tbr_blame_dict.setdefault(reviewer, {
            'tbr': [],
            'author': []
        })['tbr'].append([subject, url, timestamp, git_hash, 'TBR'])
    for url, timestamp, subject, reviewer, git_hash in commits_authored_by_user:
        tbr_blame_dict.setdefault(reviewer, {
            'tbr': [],
            'author': []
        })['author'].append([subject, url, timestamp, git_hash, 'Author'])
    tbr_data = {
        "by_user": tbr_blame_dict,
        "gitiles_prefix": gitiles_prefix,
    }
    with open(os.path.join(output_dirpath, 'search_by_user.json'), 'wb') as f:
        f.write(json.dumps(tbr_data))
Beispiel #4
0
def main(argv):
  parser = argparse.ArgumentParser(
    prog="antibody",
    description=sys.modules['__main__'].__doc__)
  antibody.add_argparse_options(parser)
  infra_libs.logs.add_argparse_options(parser)
  args = parser.parse_args(argv)

  infra_libs.logs.process_argparse_options(args)

  if args.cache_path:
    requests_cache.install_cache(args.cache_path)
  else:
    requests_cache.install_cache(os.path.join(DATA_DIR, 'rietveld_cache'))

  # Do more processing here
  LOGGER.info('Antibody starting')
  with open(args.sql_password_file, 'r') as f:
    password = f.read().strip()
  connection, cc = csql.connect(password, args.database)
  checkout = args.git_checkout_path
  if args.parse_git_rietveld or args.run_antibody:
    antibody.setup_antibody_db(cc, os.path.join(
        DATA_DIR, 'ANTIBODY_DB_schema_setup.sql'), args.database)
    git_commit_parser.upload_to_sql(cc, checkout, args.since)
    git_commits_with_review_urls = git_commit_parser.get_urls_from_git_commit(
        cc)
    for review_url in git_commits_with_review_urls:
      # cannot get access into chromereview.googleplex.com
      if not any(host in review_url for host in (
          'chromereviews.googleplex',
      )):
        code_review_parse.add_code_review_data_to_db(review_url, cc, checkout)
    csql.commit(connection)
  if args.write_html or args.run_antibody:
    if not os.path.exists(args.output_dir_path):
      os.makedirs(args.output_dir_path)
    gitiles_prefix = antibody.get_gitiles_prefix(checkout)
    if not gitiles_prefix:
      gitiles_prefix = ''
    project_name = antibody.get_project_name(checkout).lower()
    antibody.generate_antibody_ui(cc, gitiles_prefix, project_name, args.since,
        args.output_dir_path, code_review_parse.get_tbr_no_lgtm(cc, 'author'),
        args.repo_list)
  csql.close(connection, cc)
Beispiel #5
0
def main(argv):
    parser = argparse.ArgumentParser(
        prog="antibody", description=sys.modules['__main__'].__doc__)
    antibody.add_argparse_options(parser)
    infra_libs.logs.add_argparse_options(parser)
    args = parser.parse_args(argv)

    infra_libs.logs.process_argparse_options(args)

    if args.cache_path:
        requests_cache.install_cache(args.cache_path)
    else:
        requests_cache.install_cache(os.path.join(DATA_DIR, 'rietveld_cache'))

    # Do more processing here
    LOGGER.info('Antibody starting')
    with open(args.sql_password_file, 'r') as f:
        password = f.read().strip()
    connection, cc = csql.connect(password, args.database)
    checkout = args.git_checkout_path
    if args.parse_git_rietveld or args.run_antibody:
        antibody.setup_antibody_db(
            cc, os.path.join(DATA_DIR, 'ANTIBODY_DB_schema_setup.sql'),
            args.database)
        git_commit_parser.upload_to_sql(cc, checkout, args.since)
        git_commits_with_review_urls = git_commit_parser.get_urls_from_git_commit(
            cc)
        for review_url in git_commits_with_review_urls:
            # cannot get access into chromereview.googleplex.com
            if not any(host in review_url
                       for host in ('chromereviews.googleplex', )):
                code_review_parse.add_code_review_data_to_db(
                    review_url, cc, checkout)
        csql.commit(connection)
    if args.write_html or args.run_antibody:
        if not os.path.exists(args.output_dir_path):
            os.makedirs(args.output_dir_path)
        gitiles_prefix = antibody.get_gitiles_prefix(checkout)
        if not gitiles_prefix:
            gitiles_prefix = ''
        project_name = antibody.get_project_name(checkout).lower()
        antibody.generate_antibody_ui(
            cc, gitiles_prefix, project_name, args.since, args.output_dir_path,
            code_review_parse.get_tbr_no_lgtm(cc, 'author'), args.repo_list)
    csql.close(connection, cc)
Beispiel #6
0
 def test_get_tbr_no_lgtm(self):
     mock_cc = mock.MagicMock()
     mock_cc.fetchall.return_value = (
         ('https://codereview.chromium.org/993263002',
          datetime.datetime(2015, 03, 11, 07, 11, 54),
          'Reland-Changes-in-infra-to-get-bot_setup-to-work-on-GCE-Windows',
          'vadimsh', '846e3e4cb43006dbe4f026881ba8ee06835f46b1'),
         ('https://codereview.chromium.org/1051013004',
          datetime.datetime(2015, 04, 02, 01, 52,
                            29), 'Also-let-cipd-support-i686-architecture',
          'vadimsh', '8871159ca3f8d481e0e7aee7c1255fec9d5c92ee'),
         ('https://codereview.chromium.org/845263005',
          datetime.datetime(2015, 01, 13, 00, 57, 32),
          'Revert-of-Revert-Revert-of-Add-internal.DEPS-to-bot_start.-patchset-5',
          'vadimsh', 'e263ef04abaffd4e59fd9b9009bb523179212467'),
     )
     expected_out = [
         [
             'https://codereview.chromium.org/1051013004',
             '2015-04-02 01:52:29',
             'Also let cipd support i686 architecture', 'vadimsh',
             '8871159ca3f8d481e0e7aee7c1255fec9d5c92ee'
         ],
         [
             'https://codereview.chromium.org/993263002',
             '2015-03-11 07:11:54',
             'Reland Changes in infra to get bot_setup to work on GCE Windows',
             'vadimsh', '846e3e4cb43006dbe4f026881ba8ee06835f46b1'
         ],
         [
             'https://codereview.chromium.org/845263005',
             '2015-01-13 00:57:32',
             'Revert of Revert Revert of Add internal.DEPS to bot_start. patchset 5',
             'vadimsh', 'e263ef04abaffd4e59fd9b9009bb523179212467'
         ],
     ]
     out = code_review_parse.get_tbr_no_lgtm(mock_cc, 'tbr')
     self.assertItemsEqual(out, expected_out)