Exemple #1
0
 def test_retrieve(self):
     changed_files = retrieve_changed_files(self.basedir, self.repo, '', '')
     self.assertEqual(5, len(changed_files)) # as there are that much changes in the test repo
     for file in changed_files:
         if file.temp_path:
             self.assertTrue(os.path.exists(file.temp_path), "file [%s] does not exists" % file.temp_path)
Exemple #2
0
    config.add_from_args(args)
    if args.config:
        config.add_from_json(args.config)
    return config


tempdir = None
try:
    config = get_config()
    checkers = create_checkers(config)
    logging.debug('Using %s', ', '.join([c.get_name() for c in checkers]))

    errors = None
    if checkers:
        tempdir = tempfile.mkdtemp()
        changes = retrieve_changed_files(tempdir, GitRepo(), config.base, config.commit)
        logging.debug('%d changes: %s', len(changes), [str(c) for c in changes])
        errors = check(checkers)

    if errors:
        error_msg = '\n'
        for checker, checker_errors in errors.iteritems():
            error_msg += '%s %s\n' % (checker.get_name(), checker.get_documentation_url())
            for error in checker_errors:
                error_msg += '    %s\n' % error
        logging.error(error_msg)
        if args.dry_run:
            error_msg = 'dry run enabled, only logging\n'
        else:
            sys.exit(1)
except Exception, e: