From 875769d8e221d6595e26c2cd6af239b711384530 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Jun 10 2024 07:45:56 +0000 Subject: [PATCH 1/2] Do not expect the package name to be second Do not assume that the package name is second when validating the spelling of the package name with a specified namespace. This holds for CentOS itself as there is only one namespace in front of the package, e.g., `rpms` or `modules`. However when using the `centpkg-sig`, the packages reside under the SIGs' namespace adding an additional layer which yields the `rpms` for second part of the path instead of the package name. Signed-off-by: Matej Focko --- diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index 3539287..13a53a4 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -357,7 +357,7 @@ class centpkgClient(cliClient): gl = gitlab.Gitlab(_DEFAULT_API_BASE_URL) if "/" in self.args.repo[0]: project_name_with_namespace = "redhat/centos-stream/"+self.args.repo[0] - short_name=self.args.repo[0].split("/")[1] + short_name=self.args.repo[0].split("/")[-1] else: project_name_with_namespace = "redhat/centos-stream/rpms/"+self.args.repo[0] short_name=self.args.repo[0] From 8e123d3908fb42d7055fc22893ee4f6fe7350c2b Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Jun 10 2024 07:47:11 +0000 Subject: [PATCH 2/2] Use correct namespace for SIGs during validation When validating the spelling of the package during cloning, decide based on the program name whether to use the default namespace of CentOS RPMs, or the namespace dedicated to CentOS SIGs. Note that there is no reasonable way to deduce the specific SIG, so it is required to give absolute path, e.g.,`‹SIG›/rpms/‹package›` when cloning. Signed-off-by: Matej Focko --- diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index 13a53a4..afc142a 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -31,6 +31,10 @@ import os import sys _DEFAULT_API_BASE_URL = 'https://gitlab.com' +_DEFAULT_PARENT_NAMESPACE = { + 'centpkg': 'redhat/centos-stream', + 'centpkg-sig': 'CentOS', +} class centpkgClient(cliClient): @@ -355,11 +359,13 @@ class centpkgClient(cliClient): # Since gitlab allows git repos to be checked out with incorrect capitilization # we need to check the spelling when cloning gl = gitlab.Gitlab(_DEFAULT_API_BASE_URL) + parent_namespace = _DEFAULT_PARENT_NAMESPACE[self.DEFAULT_CLI_NAME] + if "/" in self.args.repo[0]: - project_name_with_namespace = "redhat/centos-stream/"+self.args.repo[0] + project_name_with_namespace = parent_namespace+"/"+self.args.repo[0] short_name=self.args.repo[0].split("/")[-1] else: - project_name_with_namespace = "redhat/centos-stream/rpms/"+self.args.repo[0] + project_name_with_namespace = parent_namespace+"/rpms/"+self.args.repo[0] short_name=self.args.repo[0] try: project = gl.projects.get(project_name_with_namespace)