-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscratch_delete.py
More file actions
34 lines (31 loc) · 1.18 KB
/
scratch_delete.py
File metadata and controls
34 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests, sys
sys.stdout.reconfigure(encoding='utf-8')
token = [line.strip().split('=', 1)[1] for line in open('.env') if line.startswith('GITHUB_TOKEN=')][0]
headers = {'Accept': 'application/vnd.github.v3+json', 'Authorization': f'token {token}'}
# Close open PRs
open_prs = [
('unjs', 'fontaine', 765)
]
for owner, repo, pull_num in open_prs:
print(f"Closing PR {owner}/{repo}#{pull_num}")
res = requests.patch(f"https://api.github.com/repos/{owner}/{repo}/pulls/{pull_num}", headers=headers, json={"state": "closed"})
if res.status_code == 200:
print("Successfully closed PR.")
else:
print(f"Failed to close PR: {res.status_code} {res.text}")
# Delete Forks
forks_to_delete = [
'namefailed/ContribAI',
'namefailed/dramatiq',
'namefailed/fontaine',
'namefailed/monorepo',
'namefailed/SewUp',
'namefailed/gnome-shellext-system-menu-hide-items'
]
for f in forks_to_delete:
print(f"Deleting fork: {f}")
res = requests.delete(f"https://api.github.com/repos/{f}", headers=headers)
if res.status_code == 204:
print("Successfully deleted fork.")
else:
print(f"Failed to delete fork: {res.status_code} {res.text}")