Skip to content

Instantly share code, notes, and snippets.

@stefanor
Created August 24, 2017 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanor/4a0b193e55c3c5c55e9d28ee953b63ca to your computer and use it in GitHub Desktop.
Save stefanor/4a0b193e55c3c5c55e9d28ee953b63ca to your computer and use it in GitHub Desktop.
local testing of lintreview
#!/usr/bin/env python
import argparse
import logging
from lintreview import git
from lintreview.config import load_config, build_review_config
from lintreview.github import get_lintrc, get_repository
from lintreview.repo import GithubRepository
from lintreview.processor import Processor
config = load_config()
log = logging.getLogger(__name__)
def main():
p = argparse.ArgumentParser()
p.add_argument('-u', '--user',
default='yola',
help='GitHub username')
p.add_argument('-r', '--repo',
help='Repo name')
p.add_argument('-p', '--pull-request',
help='Pull request number')
args = p.parse_args()
user = args.user
repo_name = args.repo
number = args.pull_request
log.info('Starting to process lint for %s/%s/%s', user, repo_name, number)
gh = get_repository(config, user, repo_name)
lintrc = get_lintrc(gh, 'pngs')
log.debug("lintrc contents '%s'", lintrc)
review_config = build_review_config(lintrc, config)
repo = GithubRepository(config, user, repo_name)
pull_request = repo.pull_request(number)
head_repo = pull_request.clone_url
private_repo = pull_request.is_private
pr_head = pull_request.head
target_branch = pull_request.target_branch
if target_branch in review_config.ignore_branches():
log.info('Pull request into ignored branch %s, skipping processing.' %
target_branch)
return
status = config.get('PULLREQUEST_STATUS', True)
if status:
repo.create_status(pr_head, 'pending', 'Lintreview processing...')
# Clone/Update repository
target_path = git.get_repo_path(user, repo_name, number, config)
git.clone_or_update(config, head_repo, target_path, pr_head,
private_repo)
processor = Processor(repo, pull_request,
target_path, config)
processor.load_changes()
processor.run_tools(review_config)
print(processor._problems.all())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment