

@must_have_addon(SHORT_NAME, 'user')
@must_have_addon(SHORT_NAME, 'node')
@must_be_addon_authorizer(SHORT_NAME)
@must_have_permission('write')
def github_create_repo(**kwargs):
    repo_name = request.json.get('name')
    if (not repo_name):
        raise HTTPError(http.BAD_REQUEST)
    node_settings = kwargs['node_addon']
    connection = GitHubClient(external_account=node_settings.external_account)
    try:
        repo = connection.create_repo(repo_name, auto_init=True)
    except GitHubError:
        raise HTTPError(http.BAD_REQUEST)
    return {
        'user': repo.owner.login,
        'repo': repo.name,
    }

dataset/ETHPy150Open CenterForOpenScience/osf.io/website/addons/github/views.py github_create_repo/original