diff --git a/github_deploy/commands/_http_utils.py b/github_deploy/commands/_http_utils.py index d736fe7..0dd699d 100644 --- a/github_deploy/commands/_http_utils.py +++ b/github_deploy/commands/_http_utils.py @@ -55,10 +55,54 @@ async def delete(*, session, url, data, headers=None): async def list_repos(*, session, org, token): headers = { - "Authorization": "token {token}".format(token=token), - "Accept": "application/vnd.github.v3+json", + "Authorization": "Bearer {token}".format(token=token), + "Accept": "application/vnd.github+json", } url = REPOS_URL.format(org=org) click.echo("Retrieving repos at {}".format(url)) response = await get(session=session, url=url, headers=headers) return response + + +async def delete_content( + *, + session, + repo, + dest, + token, + semaphore, + exists, + current_sha, +): + headers = { + "Authorization": "Bearer {token}".format(token=token), + "Accept": "application/vnd.github+json", + } + + data = {"message": "Deleted {}".format(dest)} + if exists: + data["sha"] = current_sha + + url = BASE_URL.format(repo=repo, path=dest) + + async with semaphore: + response = await delete( + session=session, url=url, data=data, headers=headers + ) + + return response + + +async def check_exists(*, session, repo, dest, token, semaphore, skip_missing): + headers = {"Authorization": "Bearer {token}".format(token=token)} + url = BASE_URL.format(repo=repo, path=dest) + + async with semaphore: + response = await get( + session=session, + url=url, + headers=headers, + skip_missing=skip_missing, + ) + + return response diff --git a/github_deploy/commands/delete.py b/github_deploy/commands/delete.py index 8ead88e..d3c2d50 100644 --- a/github_deploy/commands/delete.py +++ b/github_deploy/commands/delete.py @@ -4,54 +4,10 @@ import asyncclick as click from github_deploy.commands._constants import BASE_URL -from github_deploy.commands._http_utils import delete, get, list_repos +from github_deploy.commands._http_utils import delete, get, list_repos, delete_contents, check_exists from github_deploy.commands._utils import get_repo -async def delete_content( - *, - session, - repo, - dest, - token, - semaphore, - exists, - current_sha, -): - headers = { - "Authorization": "token {token}".format(token=token), - "Accept": "application/vnd.github.v3+json", - } - - data = {"message": "Deleted {}".format(dest)} - if exists: - data["sha"] = current_sha - - url = BASE_URL.format(repo=repo, path=dest) - - async with semaphore: - response = await delete( - session=session, url=url, data=data, headers=headers - ) - - return response - - -async def check_exists(*, session, repo, dest, token, semaphore, skip_missing): - headers = {"Authorization": "token {token}".format(token=token)} - url = BASE_URL.format(repo=repo, path=dest) - - async with semaphore: - response = await get( - session=session, - url=url, - headers=headers, - skip_missing=skip_missing, - ) - - return response - - async def handle_file_delete(*, repo, dest, token, semaphore, session): check_exists_response = await check_exists( session=session,
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: