def process_pull_request(user, repo, number, lintrc): """ Starts processing a pull request and running the various lint tools against it. """ log.info('Starting to process lint for %s/%s/%s', user, repo, number) log.debug("lintrc contents '%s'", lintrc) review_config = ReviewConfig(lintrc) if len(review_config.linters()) == 0: log.info('No configured linters, skipping processing.') return gh = github.get_client(config, user, repo) try: log.info('Loading pull request data from github.') pull_request = gh.pull_requests.get(number) head_repo = pull_request.head['repo']['git_url'] pr_head = pull_request.head['sha'] # Clone/Update repository target_path = git.get_repo_path(user, repo, number, config) git.clone_or_update(head_repo, target_path, pr_head) processor = Processor(gh, number, pr_head, target_path, config) processor.load_changes() processor.run_tools(review_config) processor.publish() log.info('Completed lint processing for %s/%s/%s' % (user, repo, number)) except BaseException, e: log.exception(e)
def process_pull_request(user, repo, number, lintrc): """ Starts processing a pull request and running the various lint tools against it. """ log.info('Starting to process lint for %s/%s/%s', user, repo, number) log.debug("lintrc contents '%s'", lintrc) review_config = ReviewConfig(lintrc) if len(review_config.linters()) == 0: log.info('No configured linters, skipping processing.') return gh = github.get_client(config, user, repo) try: log.info('Loading pull request data from github.') pull_request = gh.pull_requests.get(number) head_repo = pull_request.head['repo']['clone_url'] private_repo = pull_request.head['repo']['private'] pr_head = pull_request.head['sha'] # Clone/Update repository target_path = git.get_repo_path(user, repo, number, config) git.clone_or_update(config, head_repo, target_path, pr_head, private_repo) processor = Processor(gh, number, pr_head, target_path, config) processor.load_changes() processor.run_tools(review_config) processor.publish() log.info('Completed lint processing for %s/%s/%s' % ( user, repo, number)) except BaseException, e: log.exception(e)
def process_pull_request(user, repo, number, lintrc): """ Starts processing a pull request and running the various lint tools against it. """ log.info('Starting to process lint for %s/%s/%s', user, repo, number) log.debug("lintrc contents '%s'", lintrc) lintrc_defaults = get_lintrc_defaults(config) review_config = ReviewConfig(lintrc, lintrc_defaults) if len(review_config.linters()) == 0: log.info('No configured linters, skipping processing.') return try: log.info('Loading pull request data from github. user=%s ' 'repo=%s number=%s', user, repo, number) gh = github.get_repository(config, user, repo) pull_request = gh.pull_request(number) pr_dict = pull_request.as_dict() head_repo = pr_dict['head']['repo']['clone_url'] private_repo = pr_dict['head']['repo']['private'] pr_head = pr_dict['head']['sha'] target_branch = pr_dict['base']['ref'] if target_branch in review_config.ignore_branches(): log.info('Pull request into ignored branch %s, skipping processing.' % target_branch) return # Clone/Update repository target_path = git.get_repo_path(user, repo, number, config) git.clone_or_update(config, head_repo, target_path, pr_head, private_repo) processor = Processor(gh, number, pr_head, target_path, config) processor.load_changes() processor.run_tools(review_config) processor.publish() log.info('Completed lint processing for %s/%s/%s' % ( user, repo, number)) except BaseException, e: log.exception(e)
def test_linter_listing(self): config = ReviewConfig(sample_ini) res = config.linters() expected = ['phpcs', 'pep8', 'jshint'] eq_(res, expected)
def test_linter_listing_bad(self): config = ReviewConfig(bad_ini) res = config.linters() eq_(res, [])
def test_linter_listing(self): config = ReviewConfig(sample_ini) res = config.linters() expected = ['phpcs', 'pep8', 'jshint'] eq_(res, expected)
def test_linter_listing_bad(self): config = ReviewConfig(bad_ini) res = config.linters() eq_(res, [])