update_app_levels: Use get_apps_repo
This commit is contained in:
parent
5613dcb86d
commit
73195bc785
1 changed files with 36 additions and 31 deletions
|
@ -3,6 +3,7 @@
|
||||||
Update app catalog: commit, and create a merge request
|
Update app catalog: commit, and create a merge request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -17,12 +18,16 @@ import tomlkit
|
||||||
import tomlkit.items
|
import tomlkit.items
|
||||||
from git import Repo
|
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"
|
APPS_REPO = "YunoHost/apps"
|
||||||
|
|
||||||
CI_RESULTS_URL = "https://ci-apps.yunohost.org/ci/api/results"
|
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 = Path(__file__).resolve().parent.parent
|
||||||
TOOLS_DIR = REPO_APPS_ROOT / "tools"
|
|
||||||
|
|
||||||
|
|
||||||
def github_token() -> Optional[str]:
|
def github_token() -> Optional[str]:
|
||||||
|
@ -206,17 +211,17 @@ def main():
|
||||||
parser.add_argument("--commit", action=argparse.BooleanOptionalAction, default=True)
|
parser.add_argument("--commit", action=argparse.BooleanOptionalAction, default=True)
|
||||||
parser.add_argument("--pr", action=argparse.BooleanOptionalAction, default=True)
|
parser.add_argument("--pr", action=argparse.BooleanOptionalAction, default=True)
|
||||||
parser.add_argument("-v", "--verbose", action=argparse.BooleanOptionalAction)
|
parser.add_argument("-v", "--verbose", action=argparse.BooleanOptionalAction)
|
||||||
|
get_apps_repo.add_args(parser)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
logging.getLogger().setLevel(logging.INFO)
|
logging.getLogger().setLevel(logging.INFO)
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory(prefix="update_app_levels_") as tmpdir:
|
repo_path = get_apps_repo.from_args(args)
|
||||||
logging.info("Cloning the repository...")
|
|
||||||
apps_repo = Repo.clone_from(f"git@github.com:{APPS_REPO}", to_path=tmpdir)
|
apps_repo = Repo(repo_path)
|
||||||
assert apps_repo.working_tree_dir is not None
|
apps_toml_path = repo_path / "apps.toml"
|
||||||
apps_toml_path = Path(apps_repo.working_tree_dir) / "apps.toml"
|
|
||||||
|
|
||||||
# Load the app catalog and filter out the non-working ones
|
# Load the app catalog and filter out the non-working ones
|
||||||
catalog = tomlkit.load(apps_toml_path.open("r", encoding="utf-8"))
|
catalog = tomlkit.load(apps_toml_path.open("r", encoding="utf-8"))
|
||||||
|
|
Loading…
Reference in a new issue