From 23a564b0f9322949d3d4bed8d1163662c9a8ae52 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Sep 23 2024 12:58:40 +0000 Subject: Properly handle non-standard branch names Signed-off-by: Stephen Gallagher --- diff --git a/src/centpkg/utils.py b/src/centpkg/utils.py index b65aefe..2bee038 100644 --- a/src/centpkg/utils.py +++ b/src/centpkg/utils.py @@ -344,6 +344,10 @@ def get_repo_name(name, org="rpms"): 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 @@ def stream_mapping(csname): 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 @@ def determine_rhel_state( 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 = {