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:
Tony Breeds
2016-06-17 11:29:53 +10:00
parent 6ee15b0c7f
commit c17ec7fc40
3 changed files with 26 additions and 4 deletions

View File

@@ -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