split tag instead of parsing it using a regex

nothing says that the version number must start with a number as seen in
the gpg-pubkey packages in Fedora:

    gpg-pubkey-facb00b1-570a8081
    gpg-pubkey-c3898297-5d25cdbd
    gpg-pubkey-d38b4796-570c8cd3
    gpg-pubkey-cfc659b9-5b6eac67
This commit is contained in:
Evgeni Golov 2020-01-31 14:06:18 +01:00
parent ee7536aa5f
commit fe5d4fddb9

View file

@ -810,11 +810,14 @@ def get_project_name(tag=None, scl=None):
current working directory. Error out if neither is present.
"""
if tag is not None:
p = re.compile('(.*?)-(\d[^-]*)(-[^-]*)?$')
m = p.match(tag)
if not m:
try:
(package, _version, _release) = tag.rsplit('-', 2)
except ValueError:
try:
(package, _version) = tag.rsplit('-', 1)
except ValueError:
error_out("Unable to determine project name in tag: %s" % tag)
return m.group(1)
return package
else:
file_path = find_spec_like_file()
if not os.path.exists(file_path):