diff --git a/pmb/commands/__init__.py b/pmb/commands/__init__.py index e937643c..f37b1dd4 100644 --- a/pmb/commands/__init__.py +++ b/pmb/commands/__init__.py @@ -14,6 +14,7 @@ from .index import Index from .repo_bootstrap import RepoBootstrap from .shutdown import Shutdown from .test import Test +from .pull import Pull """New way to model pmbootstrap subcommands that can be invoked without PmbArgs.""" @@ -49,7 +50,6 @@ unmigrated_commands = [ "apkindex_parse", "config", "bootimg_analyze", - "pull", ] def run_command(args: PmbArgs): @@ -71,6 +71,8 @@ def run_command(args: PmbArgs): command = Shutdown() elif args.action == "test": command = Test(args.action_test) + elif args.action == "pull": + command = Pull() else: raise NotImplementedError(f"Command '{args.action}' is not implemented.") diff --git a/pmb/commands/pull.py b/pmb/commands/pull.py new file mode 100644 index 00000000..45def302 --- /dev/null +++ b/pmb/commands/pull.py @@ -0,0 +1,38 @@ +# Copyright 2024 Oliver Smith +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import annotations +from pmb import commands +import pmb.helpers.git +import pmb.config +import logging + + +class Pull(commands.Command): + def __init__(self): + pass + + def run(self): + failed = [] + for repo in pmb.config.git_repos.keys(): + if pmb.helpers.git.pull(repo) < 0: + failed.append(repo) + + if not failed: + return True + + logging.info("---") + logging.info("WARNING: failed to update: " + ", ".join(failed)) + logging.info("") + logging.info("'pmbootstrap pull' will only update the repositories, if:") + logging.info("* they are on an officially supported branch (e.g. master)") + logging.info("* the history is not conflicting (fast-forward is possible)") + logging.info("* the git workdirs are clean") + logging.info("You have changed mentioned repositories, so they don't meet") + logging.info("these conditions anymore.") + logging.info("") + logging.info("Fix and try again:") + for name_repo in failed: + logging.info("* " + pmb.helpers.git.get_path(name_repo)) + logging.info("---") + return False diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index 0d86e561..52600a7b 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -593,32 +593,6 @@ def bootimg_analyze(args: PmbArgs): logging.info(tmp_output) -def pull(): - failed = [] - for repo in pmb.config.git_repos.keys(): - if pmb.helpers.git.pull(repo) < 0: - failed.append(repo) - - if not failed: - return True - - logging.info("---") - logging.info("WARNING: failed to update: " + ", ".join(failed)) - logging.info("") - logging.info("'pmbootstrap pull' will only update the repositories, if:") - logging.info("* they are on an officially supported branch (e.g. master)") - logging.info("* the history is not conflicting (fast-forward is possible)") - logging.info("* the git workdirs are clean") - logging.info("You have changed mentioned repositories, so they don't meet") - logging.info("these conditions anymore.") - logging.info("") - logging.info("Fix and try again:") - for name_repo in failed: - logging.info("* " + pmb.helpers.git.get_path(name_repo)) - logging.info("---") - return False - - def lint(args: PmbArgs): packages: Sequence[str] = args.packages if not packages: