Exemple #1
0
def github_pull_request_review():
    d = request.json
    if 'zen' in d:
        log.info(f'received zen: {d["zen"]}')
        return '', 200

    action = d['action']
    gh_pr = GitHubPR.from_gh_json(d['pull_request'])

    if action == 'submitted':
        state = d['review']['state'].lower()
        if state == 'changes_requested':
            prs.review(gh_pr, state)
        else:
            # FIXME: track all reviewers, then we don't need to talk to github
            prs.review(
                gh_pr,
                overall_review_state(
                    get_reviews(gh_pr.target_ref.repo,
                                gh_pr.number))['state'])
    elif action == 'dismissed':
        # FIXME: track all reviewers, then we don't need to talk to github
        prs.review(
            gh_pr,
            overall_review_state(get_reviews(gh_pr.target_ref.repo,
                                             gh_pr.number))['state'])
    else:
        log.info(f'ignoring pull_request_review with action {action}')
    return '', 200
Exemple #2
0
def github_pull_request_review():
    d = request.json
    if 'zen' in d:
        log.info(f'received zen: {d["zen"]}')
        return '', 200

    action = d['action']
    gh_pr = GitHubPR.from_gh_json(d['pull_request'])

    if action == 'submitted':
        state = d['review']['state'].lower()
        if state == 'changes_requested':
            prs.review(gh_pr, state)
        else:
            # FIXME: track all reviewers, then we don't need to talk to github
            prs.review(
                gh_pr,
                overall_review_state(
                    get_reviews(gh_pr.target_ref.repo, gh_pr.number))['state'])
    elif action == 'dismissed':
        # FIXME: track all reviewers, then we don't need to talk to github
        prs.review(
            gh_pr,
            overall_review_state(
                get_reviews(gh_pr.target_ref.repo, gh_pr.number))['state'])
    else:
        log.info(f'ignoring pull_request_review with action {action}')
    return '', 200
Exemple #3
0
def refresh_reviews(pulls_by_target):
    for (_, pulls) in pulls_by_target.items():
        for gh_pr in pulls:
            reviews = get_repo(gh_pr.target_ref.repo.qname,
                               'pulls/' + gh_pr.number + '/reviews',
                               status_code=200)
            state = overall_review_state(reviews)['state']
            prs.review(gh_pr, state)
Exemple #4
0
def refresh_reviews(pulls_by_target):
    for (_, pulls) in pulls_by_target.items():
        for gh_pr in pulls:
            reviews = get_repo(
                gh_pr.target_ref.repo.qname,
                'pulls/' + gh_pr.number + '/reviews',
                status_code=200)
            state = overall_review_state(reviews)['state']
            prs.review(gh_pr, state)
Exemple #5
0
def test_pull_request_comment_does_not_overwrite_approval():
    data = pkg_resources.resource_string(
        __name__, 'comment-after-approve-pull-request-review.json')
    reviews = json.loads(data)

    from github import overall_review_state

    review_state = overall_review_state(reviews)

    assert review_state['state'] == 'approved'
    assert review_state['reviews']['cseed'] == 'APPROVED'
    assert 'tpoterba' not in review_state['reviews']
Exemple #6
0
def test_pull_request_comment_does_not_overwrite_approval():
    data = pkg_resources.resource_string(
        __name__,
        'comment-after-approve-pull-request-review.json')
    reviews = json.loads(data)

    from github import overall_review_state

    review_state = overall_review_state(reviews)

    assert review_state['state'] == 'approved'
    assert review_state['reviews']['cseed'] == 'APPROVED'
    assert 'tpoterba' not in review_state['reviews']