Skip to content

fix: bug with listing repositories #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 27, 2022
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 number Diff line number Diff 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 number Diff line number Diff line change
Expand Up @@ -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

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
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,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy