Add support to the history import tools for release-type
When trying to use the history import tools we need to use the correct release-type setting to validate tags. We can't use versionutils.validate_version() as it's a generator which is hard to use in a sorted() function. Insetad introduce versionutils.canonical_version() which will return the version is valid or raise a ValueError() exception. Change-Id: If10aab4c573342227e2909fd84f843c96f3abc43
This commit is contained in:
@@ -56,3 +56,11 @@ def validate_version(versionstr, release_type='std'):
|
||||
if canonical != versionstr:
|
||||
yield 'Version %r does not match canonical form %r' % \
|
||||
(versionstr, canonical)
|
||||
|
||||
|
||||
def canonical_version(versionstr, release_type='std'):
|
||||
"""Given a version string verify it is in the canonical form."""
|
||||
errors = list(validate_version(versionstr, release_type))
|
||||
if errors:
|
||||
raise ValueError(errors[-1])
|
||||
return versionstr
|
||||
|
||||
Reference in New Issue
Block a user