Indent using spaaaces

This commit is contained in:
Gabriel Augendre 2021-02-08 11:14:24 +01:00
parent 8f66c62072
commit 5f7fa85ca0
2 changed files with 58 additions and 58 deletions

View file

@ -4,52 +4,52 @@ SRHT_TOKEN = os.getenv("SRHT_TOKEN")
GITEA_TOKEN = os.getenv("GITEA_TOKEN")
def main():
gitea_headers = {"Authorization": f"token {GITEA_TOKEN}"}
res = requests.get("https://git.augendre.info/api/v1/user", headers=gitea_headers)
gitea_data = res.json()
gitea_username = gitea_data["login"]
res = requests.post(
"https://git.sr.ht/query",
headers={"Content-Type": "application/json", "Authorization": f"Bearer {SRHT_TOKEN}"},
json={
"query": """
{
me {
canonicalName
repositories(filter: {count: 35}) {
results {
name, description
}
}
}
}""",
}
)
srht_data = res.json()
username = srht_data["data"]["me"]["canonicalName"]
for repo in srht_data["data"]["me"]["repositories"]["results"]:
name = repo["name"]
description = repo["description"]
url = f"https://git.sr.ht/{username}/{name}"
gitea_headers = {"Authorization": f"token {GITEA_TOKEN}"}
res = requests.get("https://git.augendre.info/api/v1/user", headers=gitea_headers)
gitea_data = res.json()
gitea_username = gitea_data["login"]
res = requests.post(
"https://git.sr.ht/query",
headers={"Content-Type": "application/json", "Authorization": f"Bearer {SRHT_TOKEN}"},
json={
"query": """
{
me {
canonicalName
repositories(filter: {count: 35}) {
results {
name, description
}
}
}
}""",
}
)
srht_data = res.json()
username = srht_data["data"]["me"]["canonicalName"]
for repo in srht_data["data"]["me"]["repositories"]["results"]:
name = repo["name"]
description = repo["description"]
url = f"https://git.sr.ht/{username}/{name}"
gitea_data = {
"clone_addr": url,
"description": description,
"issues": True,
"labels": True,
"milestones": True,
"mirror": False,
"private": False,
"pull_requests": True,
"releases": True,
"repo_name": name,
"repo_owner": gitea_username,
"service": "git",
"uid": 0,
"wiki": True
}
res = requests.post("https://git.augendre.info/api/v1/repos/migrate", headers=gitea_headers, json=gitea_data)
gitea_data = {
"clone_addr": url,
"description": description,
"issues": True,
"labels": True,
"milestones": True,
"mirror": False,
"private": False,
"pull_requests": True,
"releases": True,
"repo_name": name,
"repo_owner": gitea_username,
"service": "git",
"uid": 0,
"wiki": True
}
res = requests.post("https://git.augendre.info/api/v1/repos/migrate", headers=gitea_headers, json=gitea_data)
if __name__ == "__main__":
main()
main()

View file

@ -4,20 +4,20 @@ GITEA_TOKEN = os.getenv("GITEA_TOKEN")
BASE_URL = "https://git.augendre.info/api/v1"
def main():
session = requests.Session()
session.headers.update({"Authorization": f"token {GITEA_TOKEN}"})
res = session.get(f"{BASE_URL}/user/repos", params={"limit": 40})
repos = res.json()
session = requests.Session()
session.headers.update({"Authorization": f"token {GITEA_TOKEN}"})
res = session.get(f"{BASE_URL}/user/repos", params={"limit": 40})
repos = res.json()
for repo in repos:
full_name = repo["full_name"]
url = f"{BASE_URL}/repos/{full_name}"
res = session.patch(url, json={
'has_issues': True,
'internal_tracker': {'enable_time_tracker': False, 'allow_only_contributors_to_track_time': True, 'enable_issue_dependencies': True}
})
print(full_name, res.status_code)
for repo in repos:
full_name = repo["full_name"]
url = f"{BASE_URL}/repos/{full_name}"
res = session.patch(url, json={
'has_issues': True,
'internal_tracker': {'enable_time_tracker': False, 'allow_only_contributors_to_track_time': True, 'enable_issue_dependencies': True}
})
print(full_name, res.status_code)
if __name__ == "__main__":
main()
main()