2021-02-07 08:38:37 +01:00
|
|
|
import requests, pprint, os
|
2021-02-07 08:06:36 +01:00
|
|
|
|
2021-02-07 08:38:37 +01:00
|
|
|
SRHT_TOKEN = os.getenv("SRHT_TOKEN")
|
|
|
|
GITEA_TOKEN = os.getenv("GITEA_TOKEN")
|
2021-02-07 08:06:36 +01:00
|
|
|
|
|
|
|
def main():
|
2021-02-08 11:14:24 +01:00
|
|
|
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}"
|
2021-02-07 08:06:36 +01:00
|
|
|
|
2021-02-08 11:14:24 +01:00
|
|
|
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)
|
2021-02-07 08:06:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-02-08 11:14:24 +01:00
|
|
|
main()
|