#110 Properly handle non-standard branch names
Merged 2 months ago by tdawson. Opened 2 months ago by sgallagh.
centos/ sgallagh/centpkg determine_rhel_state  into  develop

file modified
+20 -2
@@ -344,6 +344,10 @@ 

      return "%s/%s" % (org, repo_name)

  

  

+ class StreamMappingError(RHELError):

+     pass

+ 

+ 

  def stream_mapping(csname):

      """

      Given a CentOS Stream name, map it to the corresponding RHEL name.
@@ -366,7 +370,7 @@ 

          return 10, "rhel-10"

      if csname == "c11s" or csname == "cs11":

          return 11, "rhel-11"

-     return None

+     raise StreamMappingError(f"{csname} is not a Stream branch")

  

  

  def does_branch_exist(rhel_dist_git, namespace, repo_name, branch):
@@ -525,7 +529,21 @@ 

      except (ConnectionError, HTTPError) as e:

          raise RHELError("Could not retrieve distrobaker config. Are you on the VPN?")

  

-     x_version, rhel_version = stream_mapping(cs_branch)

+     try:

+         x_version, rhel_version = stream_mapping(cs_branch)

+     except StreamMappingError as e:

+         # This is not a standard branch name, so it's probably either a custom

+         # branch or a module stream branch. Either way, we'll return it as-is

+         # and always treat it as if it is in enforcing mode.

+         return rhel_state_nt(

+             latest_version=cs_branch,

+             target_version=cs_branch,

+             rule_branch=cs_branch,

+             phase=pp_phase_maintenance,

+             rhel_target_default="none",

+             enforcing=True,

+             synced=False,

+         )

  

      # Query the "package pages" API for the current active Y-stream release

      request_params = {

Sorry for taking so long on this. It took extra testing.
But all the testing shows that it does what it is supposed to.

Pull-Request has been merged by tdawson

2 months ago
Metadata