Check package spelling (CS-767)

Signed-off-by: Troy Dawson <tdawson@redhat.com>
This commit is contained in:
Troy Dawson 2023-06-06 14:21:36 -07:00
parent 87795b6ebf
commit 5fd982bf00

View file

@ -25,6 +25,7 @@ from pyrpkg import rpkgError
from six.moves.urllib_parse import urlparse from six.moves.urllib_parse import urlparse
import six.moves.configparser as ConfigParser import six.moves.configparser as ConfigParser
import gitlab
import json import json
import koji import koji
import os import os
@ -276,3 +277,26 @@ class centpkgClient(cliClient):
def request_gated_side_tag(self): def request_gated_side_tag(self):
self.args.suffix = "stack-gate" self.args.suffix = "stack-gate"
super(centpkgClient, self).request_side_tag() super(centpkgClient, self).request_side_tag()
def clone(self):
# 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)
if "modules/" in self.args.repo[0]:
project_name_with_namespace = "redhat/centos-stream/"+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]
short_name=self.args.repo[0]
try:
project = gl.projects.get(project_name_with_namespace)
except gitlab.exceptions.GitlabGetError as e:
self.log.info("There is no repository with the given name. Did you spell it correctly?")
self.log.info("Fatal: ")
self.log.info(e)
raise SystemExit
if not project.name == short_name:
self.log.info("Fatal: ")
self.log.info("Project name is wrong: " + short_name + " it should be: " + project.name)
raise SystemExit
super(centpkgClient, self).clone()