mirror of
https://github.com/YunoHost/yunodevtools.git
synced 2024-09-03 20:16:19 +02:00
refactor(clone_packages): white lines to make code more readables
This commit is contained in:
parent
5f1d76a0f0
commit
fb34339a66
1 changed files with 14 additions and 1 deletions
|
@ -16,20 +16,26 @@ def generate_catalog_repo_list():
|
|||
# list the apps in the catalog
|
||||
|
||||
apps_repos = []
|
||||
|
||||
for app in catalog:
|
||||
url = catalog.get(app)["url"]
|
||||
name = url.split("/")[-1] # get the last part of the URL as the repo name
|
||||
|
||||
apps_repos.append([name, url])
|
||||
|
||||
return apps_repos
|
||||
|
||||
|
||||
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 = []
|
||||
|
||||
data = requests.get("https://git.yunohost.org/api/v1/repos/search?topic=false&includeDesc=false&priority_owner_id=17&mode=mirror").json()["data"]
|
||||
|
||||
for repo in data:
|
||||
existing_clones.append(repo["name"])
|
||||
|
||||
return existing_clones
|
||||
|
||||
|
||||
|
@ -48,6 +54,7 @@ def generate_mirrors():
|
|||
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,
|
||||
"auth_token": GITHUB_TOKEN,
|
||||
|
@ -56,13 +63,17 @@ def generate_mirrors():
|
|||
"repo_owner": "YunoHost-Apps",
|
||||
"service": "github"
|
||||
}
|
||||
|
||||
create_mirror = requests.post("https://git.yunohost.org/api/v1/repos/migrate", headers=api_header, params=f"access_token={FORGEJO_TOKEN}", json=create_mirror_data)
|
||||
|
||||
if create_mirror.status_code != 201:
|
||||
if create_mirror.status_code == 409:
|
||||
print(f"A repo named '{repo_name}' is already existing.")
|
||||
|
||||
if create_mirror.status_code == 422:
|
||||
print(f"We're rate limited. Waiting for 1 minute before continuing.")
|
||||
time.sleep(60)
|
||||
|
||||
else:
|
||||
raise Exception('Request failed:', create_mirror.status_code, create_mirror.text)
|
||||
|
||||
|
@ -74,7 +85,9 @@ def generate_mirrors():
|
|||
"has_releases": False,
|
||||
"has_wiki": False
|
||||
}
|
||||
|
||||
settings_mirror = requests.patch(f"https://git.yunohost.org/api/v1/repos/YunoHost-Apps/{repo_name}", headers=api_header, params=f"access_token={FORGEJO_TOKEN}", json=settings_mirror_data)
|
||||
|
||||
if settings_mirror.status_code != 200:
|
||||
raise Exception('Request failed:', settings_mirror.text)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue