From aededb449c1d5d39983bab646a80549f59b856ff Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Aug 28 2023 22:52:41 +0000 Subject: Add current-state option Signed-off-by: Troy Dawson --- diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index b571b8d..ade5390 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -50,6 +50,7 @@ class centpkgClient(cliClient): def setup_centos_subparsers(self): self.register_do_fork() self.register_request_gated_side_tag() + self.register_current_state() def register_do_fork(self): help_msg = 'Create a new fork of the current repository' @@ -132,6 +133,61 @@ class centpkgClient(cliClient): msg = "Remote with name '{0}' already exists." self.log.info(msg.format(remote_name)) + def register_current_state(self): + """Register command line parser for subcommand current-state""" + parser = self.subparsers.add_parser( + "current-state", + help="Show the phase and state of current dist-git branch - Internal Only", + ) + parser.set_defaults(command=self.request_current_state) + + # FIXME: This is alot of duplication. + # Get it working now. De-duplicate later + def request_current_state(self): + # Only run if we have internal configuraions, or scratch + internal_config_file = "/etc/rpkg/centpkg_internal.conf" + if os.path.exists(internal_config_file): + # Get our internal only variables + cfg = ConfigParser.SafeConfigParser() + cfg.read(internal_config_file) + pp_api_url = config_get_safely(cfg, "centpkg.internal", 'pp_api_url') + gitbz_query_url = config_get_safely(cfg, "centpkg.internal", 'gitbz_query_url') + rhel_dist_git = config_get_safely(cfg, "centpkg.internal", 'rhel_dist_git') + + # Find out divergent branch and stabalization + self.log.info("Checking current state:") + stream_version = self.cmd.target.split('-')[0] + rhel_version = centpkg.utils.stream_mapping(stream_version) + try: + active_y, in_stabilization = centpkg.utils.determine_active_y_version(rhel_version, pp_api_url) + except AssertionError as e: + self.log.error(" Error: centpkg cannot determine the development phase.") + self.log.error(" Please file an issue at https://git.centos.org/centos/centpkg") + self.log.error(" Workaround: Use the --rhel-target option") + self.log.error("Exiting") + raise SystemExit(1) + divergent_branch = centpkg.utils.does_divergent_branch_exist( + self.cmd.repo_name, + rhel_version, + active_y, + rhel_dist_git, + pp_api_url, + "rpms") + # Good to know + if in_stabilization : + self.log.info(" we are in stabilization mode.") + else: + self.log.info(" we are not in stabilization mode.") + if divergent_branch : + self.log.info(" a divergent branch was found.") + else: + self.log.info(" a divergent branch was not found.") + else: + self.log.error("NO INTERNAL CONFIGURATION") + self.log.error("Hint: If you are internal, install the rhel-packager package from https://download.devel.redhat.com/rel-eng/RCMTOOLS/latest-RCMTOOLS-2-RHEL-9/compose/BaseOS/x86_64/os/Packages/") + self.log.error("Exiting") + raise SystemExit(1) + # Overloaded build def register_build(self): # Do all the work from the super class