1
0
Fork 0

update_app_levels: Use get_apps_repo

This commit is contained in:
Félix Piédallu 2024-08-11 18:23:46 +02:00 committed by Salamandar
parent 5613dcb86d
commit 73195bc785

View file

@ -3,6 +3,7 @@
Update app catalog: commit, and create a merge request
"""
import sys
import argparse
import logging
import tempfile
@ -17,12 +18,16 @@ import tomlkit
import tomlkit.items
from git import Repo
# add apps/tools to sys.path
sys.path.insert(0, str(Path(__file__).parent.parent))
from appslib import get_apps_repo
APPS_REPO = "YunoHost/apps"
CI_RESULTS_URL = "https://ci-apps.yunohost.org/ci/api/results"
REPO_APPS_ROOT = Path(Repo(__file__, search_parent_directories=True).working_dir)
TOOLS_DIR = REPO_APPS_ROOT / "tools"
TOOLS_DIR = Path(__file__).resolve().parent.parent
def github_token() -> Optional[str]:
@ -206,17 +211,17 @@ def main():
parser.add_argument("--commit", action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("--pr", action=argparse.BooleanOptionalAction, default=True)
parser.add_argument("-v", "--verbose", action=argparse.BooleanOptionalAction)
get_apps_repo.add_args(parser)
args = parser.parse_args()
logging.getLogger().setLevel(logging.INFO)
if args.verbose:
logging.getLogger().setLevel(logging.DEBUG)
with tempfile.TemporaryDirectory(prefix="update_app_levels_") as tmpdir:
logging.info("Cloning the repository...")
apps_repo = Repo.clone_from(f"git@github.com:{APPS_REPO}", to_path=tmpdir)
assert apps_repo.working_tree_dir is not None
apps_toml_path = Path(apps_repo.working_tree_dir) / "apps.toml"
repo_path = get_apps_repo.from_args(args)
apps_repo = Repo(repo_path)
apps_toml_path = repo_path / "apps.toml"
# Load the app catalog and filter out the non-working ones
catalog = tomlkit.load(apps_toml_path.open("r", encoding="utf-8"))