From 5fd982bf002697c81e3d07246baaecc3da59df6d Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Jun 06 2023 21:21:36 +0000 Subject: Check package spelling (CS-767) Signed-off-by: Troy Dawson --- diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index 44e27f8..06e73e1 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -25,6 +25,7 @@ from pyrpkg import rpkgError from six.moves.urllib_parse import urlparse import six.moves.configparser as ConfigParser +import gitlab import json import koji import os @@ -276,3 +277,26 @@ class centpkgClient(cliClient): def request_gated_side_tag(self): self.args.suffix = "stack-gate" 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()