Skip to content

Commit 8f17800

Browse files
authored
Merge pull request #25 from tj-python/fix/bug-with-listing-repositories
fix: bug with listing repositories
2 parents 8d073c6 + d8700ba commit 8f17800

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

github_deploy/commands/_http_utils.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,54 @@ async def delete(*, session, url, data, headers=None):
5555

5656
async def list_repos(*, session, org, token):
5757
headers = {
58-
"Authorization": "token {token}".format(token=token),
59-
"Accept": "application/vnd.github.v3+json",
58+
"Authorization": "Bearer {token}".format(token=token),
59+
"Accept": "application/vnd.github+json",
6060
}
6161
url = REPOS_URL.format(org=org)
6262
click.echo("Retrieving repos at {}".format(url))
6363
response = await get(session=session, url=url, headers=headers)
6464
return response
65+
66+
67+
async def delete_content(
68+
*,
69+
session,
70+
repo,
71+
dest,
72+
token,
73+
semaphore,
74+
exists,
75+
current_sha,
76+
):
77+
headers = {
78+
"Authorization": "Bearer {token}".format(token=token),
79+
"Accept": "application/vnd.github+json",
80+
}
81+
82+
data = {"message": "Deleted {}".format(dest)}
83+
if exists:
84+
data["sha"] = current_sha
85+
86+
url = BASE_URL.format(repo=repo, path=dest)
87+
88+
async with semaphore:
89+
response = await delete(
90+
session=session, url=url, data=data, headers=headers
91+
)
92+
93+
return response
94+
95+
96+
async def check_exists(*, session, repo, dest, token, semaphore, skip_missing):
97+
headers = {"Authorization": "Bearer {token}".format(token=token)}
98+
url = BASE_URL.format(repo=repo, path=dest)
99+
100+
async with semaphore:
101+
response = await get(
102+
session=session,
103+
url=url,
104+
headers=headers,
105+
skip_missing=skip_missing,
106+
)
107+
108+
return response

github_deploy/commands/delete.py

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,10 @@
44
import asyncclick as click
55

66
from github_deploy.commands._constants import BASE_URL
7-
from github_deploy.commands._http_utils import delete, get, list_repos
7+
from github_deploy.commands._http_utils import delete, get, list_repos, delete_contents, check_exists
88
from github_deploy.commands._utils import get_repo
99

1010

11-
async def delete_content(
12-
*,
13-
session,
14-
repo,
15-
dest,
16-
token,
17-
semaphore,
18-
exists,
19-
current_sha,
20-
):
21-
headers = {
22-
"Authorization": "token {token}".format(token=token),
23-
"Accept": "application/vnd.github.v3+json",
24-
}
25-
26-
data = {"message": "Deleted {}".format(dest)}
27-
if exists:
28-
data["sha"] = current_sha
29-
30-
url = BASE_URL.format(repo=repo, path=dest)
31-
32-
async with semaphore:
33-
response = await delete(
34-
session=session, url=url, data=data, headers=headers
35-
)
36-
37-
return response
38-
39-
40-
async def check_exists(*, session, repo, dest, token, semaphore, skip_missing):
41-
headers = {"Authorization": "token {token}".format(token=token)}
42-
url = BASE_URL.format(repo=repo, path=dest)
43-
44-
async with semaphore:
45-
response = await get(
46-
session=session,
47-
url=url,
48-
headers=headers,
49-
skip_missing=skip_missing,
50-
)
51-
52-
return response
53-
54-
5511
async def handle_file_delete(*, repo, dest, token, semaphore, session):
5612
check_exists_response = await check_exists(
5713
session=session,

0 commit comments

Comments
 (0)