Indent using spaaaces
This commit is contained in:
parent
8f66c62072
commit
5f7fa85ca0
2 changed files with 58 additions and 58 deletions
90
migrate.py
90
migrate.py
|
@ -4,52 +4,52 @@ SRHT_TOKEN = os.getenv("SRHT_TOKEN")
|
||||||
GITEA_TOKEN = os.getenv("GITEA_TOKEN")
|
GITEA_TOKEN = os.getenv("GITEA_TOKEN")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
gitea_headers = {"Authorization": f"token {GITEA_TOKEN}"}
|
gitea_headers = {"Authorization": f"token {GITEA_TOKEN}"}
|
||||||
res = requests.get("https://git.augendre.info/api/v1/user", headers=gitea_headers)
|
res = requests.get("https://git.augendre.info/api/v1/user", headers=gitea_headers)
|
||||||
gitea_data = res.json()
|
gitea_data = res.json()
|
||||||
gitea_username = gitea_data["login"]
|
gitea_username = gitea_data["login"]
|
||||||
res = requests.post(
|
res = requests.post(
|
||||||
"https://git.sr.ht/query",
|
"https://git.sr.ht/query",
|
||||||
headers={"Content-Type": "application/json", "Authorization": f"Bearer {SRHT_TOKEN}"},
|
headers={"Content-Type": "application/json", "Authorization": f"Bearer {SRHT_TOKEN}"},
|
||||||
json={
|
json={
|
||||||
"query": """
|
"query": """
|
||||||
{
|
{
|
||||||
me {
|
me {
|
||||||
canonicalName
|
canonicalName
|
||||||
repositories(filter: {count: 35}) {
|
repositories(filter: {count: 35}) {
|
||||||
results {
|
results {
|
||||||
name, description
|
name, description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}""",
|
}""",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
srht_data = res.json()
|
srht_data = res.json()
|
||||||
username = srht_data["data"]["me"]["canonicalName"]
|
username = srht_data["data"]["me"]["canonicalName"]
|
||||||
for repo in srht_data["data"]["me"]["repositories"]["results"]:
|
for repo in srht_data["data"]["me"]["repositories"]["results"]:
|
||||||
name = repo["name"]
|
name = repo["name"]
|
||||||
description = repo["description"]
|
description = repo["description"]
|
||||||
url = f"https://git.sr.ht/{username}/{name}"
|
url = f"https://git.sr.ht/{username}/{name}"
|
||||||
|
|
||||||
gitea_data = {
|
gitea_data = {
|
||||||
"clone_addr": url,
|
"clone_addr": url,
|
||||||
"description": description,
|
"description": description,
|
||||||
"issues": True,
|
"issues": True,
|
||||||
"labels": True,
|
"labels": True,
|
||||||
"milestones": True,
|
"milestones": True,
|
||||||
"mirror": False,
|
"mirror": False,
|
||||||
"private": False,
|
"private": False,
|
||||||
"pull_requests": True,
|
"pull_requests": True,
|
||||||
"releases": True,
|
"releases": True,
|
||||||
"repo_name": name,
|
"repo_name": name,
|
||||||
"repo_owner": gitea_username,
|
"repo_owner": gitea_username,
|
||||||
"service": "git",
|
"service": "git",
|
||||||
"uid": 0,
|
"uid": 0,
|
||||||
"wiki": True
|
"wiki": True
|
||||||
}
|
}
|
||||||
res = requests.post("https://git.augendre.info/api/v1/repos/migrate", headers=gitea_headers, json=gitea_data)
|
res = requests.post("https://git.augendre.info/api/v1/repos/migrate", headers=gitea_headers, json=gitea_data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -4,20 +4,20 @@ GITEA_TOKEN = os.getenv("GITEA_TOKEN")
|
||||||
BASE_URL = "https://git.augendre.info/api/v1"
|
BASE_URL = "https://git.augendre.info/api/v1"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
session.headers.update({"Authorization": f"token {GITEA_TOKEN}"})
|
session.headers.update({"Authorization": f"token {GITEA_TOKEN}"})
|
||||||
res = session.get(f"{BASE_URL}/user/repos", params={"limit": 40})
|
res = session.get(f"{BASE_URL}/user/repos", params={"limit": 40})
|
||||||
repos = res.json()
|
repos = res.json()
|
||||||
|
|
||||||
for repo in repos:
|
for repo in repos:
|
||||||
full_name = repo["full_name"]
|
full_name = repo["full_name"]
|
||||||
url = f"{BASE_URL}/repos/{full_name}"
|
url = f"{BASE_URL}/repos/{full_name}"
|
||||||
res = session.patch(url, json={
|
res = session.patch(url, json={
|
||||||
'has_issues': True,
|
'has_issues': True,
|
||||||
'internal_tracker': {'enable_time_tracker': False, 'allow_only_contributors_to_track_time': True, 'enable_issue_dependencies': True}
|
'internal_tracker': {'enable_time_tracker': False, 'allow_only_contributors_to_track_time': True, 'enable_issue_dependencies': True}
|
||||||
})
|
})
|
||||||
print(full_name, res.status_code)
|
print(full_name, res.status_code)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue