コード例 #1
0
    def test_get_project_name(self):
        with infra_libs.temporary_directory(prefix='antibody-test') as dirname:
            with open(os.path.join(dirname, 'codereview.settings'), 'w') as f:
                f.writelines([
                    'This file is used by gcl to get repository specific information.\n',
                    'CODE_REVIEW_SERVER: https://codereview.chromium.org\n',
                    'VIEW_VC: https://chromium.googlesource.com/infra/infra/+/\n',
                    'CC_LIST: [email protected]\n',
                    'PROJECT: infra\n',
                ])
            self.assertEqual(antibody.get_project_name(dirname), 'infra')

            with open(os.path.join(dirname, 'codereview.settings'), 'w') as f:
                f.writelines([
                    'CC_LIST: [email protected]\n',
                    'VIEW_VC: https://chromium.googlesource.com/infra/infra/+/\n',
                ])
            self.assertEqual(antibody.get_project_name(dirname), None)
コード例 #2
0
ファイル: antibody_test.py プロジェクト: eunchong/infra
  def test_get_project_name(self):
    with infra_libs.temporary_directory(prefix='antibody-test') as dirname:
      with open(os.path.join(dirname, 'codereview.settings'), 'w') as f:
        f.writelines([
          'This file is used by gcl to get repository specific information.\n',
          'CODE_REVIEW_SERVER: https://codereview.chromium.org\n',
          'VIEW_VC: https://chromium.googlesource.com/infra/infra/+/\n',
          'CC_LIST: [email protected]\n',
          'PROJECT: infra\n',
        ])
      self.assertEqual(antibody.get_project_name(dirname),
                       'infra')

      with open(os.path.join(dirname, 'codereview.settings'), 'w') as f:
        f.writelines([
          'CC_LIST: [email protected]\n',
          'VIEW_VC: https://chromium.googlesource.com/infra/infra/+/\n',
        ])
      self.assertEqual(antibody.get_project_name(dirname), None)
コード例 #3
0
ファイル: __main__.py プロジェクト: keelerh/chrome_infra
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)
コード例 #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)