def from_gh_json(d, target_sha=None): assert 'state' in d, d assert 'number' in d, d assert 'title' in d, d assert 'head' in d, d assert 'base' in d, d return GitHubPR(d['state'], str(d['number']), str(d['title']), FQSHA.from_gh_json(d['head']), FQSHA.from_gh_json(d['base']).ref, target_sha)
def github_pull_request(): d = request.json assert 'action' in d, d assert 'pull_request' in d, d action = d['action'] if action in ('opened', 'synchronize'): target_sha = FQSHA.from_gh_json(d['pull_request']['base']).sha gh_pr = GitHubPR.from_gh_json(d['pull_request'], target_sha) prs.pr_push(gh_pr) elif action == 'closed': gh_pr = GitHubPR.from_gh_json(d['pull_request']) log.info(f'forgetting closed pr {gh_pr.short_str()}') prs.forget(gh_pr.source.ref, gh_pr.target_ref) else: log.info(f'ignoring pull_request with action {action}') return '', 200
def github_pull_request(): d = request.json if 'zen' in d: log.info(f'received zen: {d["zen"]}') return '', 200 assert 'action' in d, d assert 'pull_request' in d, d action = d['action'] if action in ('opened', 'synchronize'): target_sha = FQSHA.from_gh_json(d['pull_request']['base']).sha gh_pr = GitHubPR.from_gh_json(d['pull_request'], target_sha) prs.pr_push(gh_pr) elif action == 'closed': gh_pr = GitHubPR.from_gh_json(d['pull_request']) log.info(f'forgetting closed pr {gh_pr.short_str()}') prs.forget(gh_pr.source.ref, gh_pr.target_ref) else: log.info(f'ignoring pull_request with action {action}') return '', 200