Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions github_deploy/commands/_http_utils.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
46 changes: 1 addition & 45 deletions github_deploy/commands/delete.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,54 +4,10 @@
importasyncclickasclick

fromgithub_deploy.commands._constantsimportBASE_URL
fromgithub_deploy.commands._http_utilsimportdelete, get, list_repos
fromgithub_deploy.commands._http_utilsimportdelete, get, list_repos, delete_contents, check_exists

Check notice

Code scanning / Pylint (reported by Codacy)

Unused delete_contents imported from github_deploy.commands._http_utils

Unused delete_contents imported from github_deploy.commands._http_utils

Check notice

Code scanning / Pylint (reported by Codacy)

Unused get imported from github_deploy.commands._http_utils

Unused get imported from github_deploy.commands._http_utils

Check notice

Code scanning / Pylint (reported by Codacy)

Unused delete imported from github_deploy.commands._http_utils

Unused delete imported from github_deploy.commands._http_utils
fromgithub_deploy.commands._utilsimportget_repo


asyncdefdelete_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)}
ifexists:
data["sha"] =current_sha

url=BASE_URL.format(repo=repo, path=dest)

asyncwithsemaphore:
response=awaitdelete(
session=session, url=url, data=data, headers=headers
)

returnresponse


asyncdefcheck_exists(*, session, repo, dest, token, semaphore, skip_missing):
headers={"Authorization": "token{token}".format(token=token)}
url=BASE_URL.format(repo=repo, path=dest)

asyncwithsemaphore:
response=awaitget(
session=session,
url=url,
headers=headers,
skip_missing=skip_missing,
)

returnresponse


asyncdefhandle_file_delete(*, repo, dest, token, semaphore, session):
check_exists_response=awaitcheck_exists(
session=session,
Expand Down