def acknowledge_merge_on_travis()

in webhook-app/webhooks.py [0:0]


def acknowledge_merge_on_travis(data):
    """When a user comments on a pull request with one of the automerge
    triggers (e.g. merge on green), this hook will add the 'automerge'
    label.

    Issue comment data reference:
    https://developer.github.com/v3/activity/events/types/#issuecommentevent
    """
    if data.get('action') != 'created':
        return

    # Make sure it's a PR.
    if not github_helper.is_pull_request(data):
        return

    # If comment has trigger text.
    comment = data['comment']

    if not check_for_auto_merge_trigger(comment['body']):
        return

    # If user is a collaborator.
    gh = github_helper.get_client()
    repository = github_helper.get_repository(gh, data)

    if not repository.is_collaborator(data['sender']['login']):
        logging.info(
            '{} is not an owner and is trying to tell me what to do.'.format(
                data['sender']['login']))

    # Write a comment about it.
    pr = github_helper.get_pull_request(gh, data)
    pr.create_comment(
        'Okay! I\'ll merge when all statuses are green and all reviewers '
        'approve.')
    pr.issue().add_labels('automerge')
    pr.issue().assign(github_helper.github_user())