Пример #1
0
def _set_status(project, commit_sha, status):
    descriptions = {
        'success': 'All good!',
        'failure': 'There are squash! or fixup! commits in the pull request.',
    }
    data = {
        'context': 'squash! protector',
        'state': status,
    }
    if status in descriptions:
        data['description'] = descriptions[status]
    return github.post(
        'repos/{}/statuses/{}'.format(project.repo, commit_sha),
        data=data,
        access_token=project.access_token,
    )
Пример #2
0
def create_hook(project):
    hook_url = url_for(
        'events.receive',
        project_id=project.id,
        _external=True,
    )
    response = github.post(
        'repos/{0.repo}/hooks'.format(project),
        access_token=project.access_token,
        data={
            'name': 'web',
            'config': {
                'url': hook_url,
                'content_type': 'json',
            },
            'events': 'pull_request',
            'active': True,
        },
    )
    return response