smol improvements

This commit is contained in:
OniriCorpe 2024-05-05 01:24:29 +02:00
parent 78df7de37f
commit f0931e5f8c

View file

@ -14,6 +14,8 @@ catalog = toml.load(open(os.path.join(APPS_REPO_ROOT, "apps.toml"), encoding="ut
def generate_catalog_repo_list():
# list the apps in the catalog
apps_repos = []
for app in catalog:
url = catalog.get(app)["url"]
@ -22,7 +24,9 @@ def generate_catalog_repo_list():
return apps_repos
def generate_actual_repo_list():
def generate_mirror_list():
# list the existing mirrors on our forgejo
data = requests.get("https://git.yunohost.org/api/v1/repos/search?topic=false&includeDesc=false&priority_owner_id=17&mode=mirror").json()["data"]
existing_clones = []
for repo in data:
@ -31,11 +35,17 @@ def generate_actual_repo_list():
def generate_mirrors():
for app in generate_catalog_repo_list():
app_catalog = generate_catalog_repo_list()
mirror_list = generate_mirror_list()
for app in app_catalog:
repo_name = app[0]
repo_url = app[1]
if app[0] not in generate_actual_repo_list():
if app[0] not in mirror_list:
print(f"A mirror for '{repo_name}' must be created.")
api_header = {'Content-type': 'application/json', 'Authorization': '{FORGEJO_TOKEN}'}
create_mirror_data = {
"clone_addr": repo_url,
@ -54,6 +64,7 @@ def generate_mirrors():
time.sleep(60)
else:
raise Exception('Request failed:', create_mirror.status_code, create_mirror.text)
else:
# configuring properly the new repository
settings_mirror_data = {