More repos in the get_external_repo returns and error

Fixes: https://pagure.io/koji/issue/3033
This commit is contained in:
Jana Cupova 2021-09-17 13:13:15 +02:00 committed by Tomas Kopecek
parent 390a633afd
commit 7096bddc4f
2 changed files with 38 additions and 2 deletions

View file

@ -3759,8 +3759,12 @@ def get_external_repo(info, strict=False, event=None):
:returns: a map containing the id, name, and url of the repository.
"""
repos = get_external_repos(info, event=event)
if repos:
if len(repos) == 1:
return repos[0]
elif len(repos) > 1:
# a very defective situation which should never occur
# (name/id should be exact identification)
raise koji.GenericError('More than one repo in the result.')
else:
if strict:
raise koji.GenericError('No such repo: %s' % info)