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:
parent
6ee15b0c7f
commit
c17ec7fc40
@ -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
|
||||
|
@ -23,7 +23,7 @@ Use git as the canonical source of version numbers.
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from distutils.version import StrictVersion
|
||||
from openstack_releases.versionutils import canonical_version
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
@ -69,6 +69,9 @@ parser.add_argument('repo', help='repository directory')
|
||||
parser.add_argument('--announce', default='openstack-dev@lists.openstack.org',
|
||||
help=('Where to send release announcements. '
|
||||
'(Default: %(default)s)'))
|
||||
parser.add_argument('--release-type', dest='release_type', default='std',
|
||||
help=('Which release-type to use for this deliverable'
|
||||
'(Default: %(default)s)'))
|
||||
args = parser.parse_args()
|
||||
|
||||
before = os.getcwd()
|
||||
@ -123,9 +126,11 @@ for series, milestones in sorted(series_data.items()):
|
||||
f.write('launchpad: %s\n' % args.project)
|
||||
f.write('team: %s\n' % args.project)
|
||||
f.write('send-announcements-to: %s\n' % args.announce)
|
||||
f.write('release-type: %s\n' % args.release_type)
|
||||
f.write('releases:\n')
|
||||
milestones_sorted = sorted(milestones.items(),
|
||||
key=lambda x: StrictVersion(x[0]))
|
||||
milestones_sorted = \
|
||||
sorted(milestones.items(),
|
||||
key=lambda x: canonical_version(x[0], args.release_type))
|
||||
for milestone, milestone_data in milestones_sorted:
|
||||
f.write(' - version: %s\n' % milestone)
|
||||
f.write(' projects:\n')
|
||||
|
@ -23,6 +23,8 @@ Use launchpad as the canonical source of version numbers.
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from openstack_releases.versionutils import canonical_version
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
@ -45,6 +47,9 @@ parser.add_argument('--series', help='series to scan')
|
||||
parser.add_argument('--announce', default='openstack-dev@lists.openstack.org',
|
||||
help=('Where to send release announcements. '
|
||||
'(Default: %(default)s)'))
|
||||
parser.add_argument('--release-type', dest='release_type', default='std',
|
||||
help=('Which release-type to use for this deliverable '
|
||||
'(Default: %(default)s)'))
|
||||
args = parser.parse_args()
|
||||
|
||||
# Connect to LP
|
||||
@ -109,8 +114,12 @@ for series, milestones in sorted(series_data.items()):
|
||||
f.write('launchpad: %s\n' % args.project)
|
||||
f.write('team: %s\n' % args.project)
|
||||
f.write('send-announcements-to: %s\n' % args.announce)
|
||||
f.write('release-type: %s\n' % args.release_type)
|
||||
f.write('releases:\n')
|
||||
for milestone, milestone_data in sorted(milestones.items()):
|
||||
milestones_sorted = \
|
||||
sorted(milestones.items(),
|
||||
key=lambda x: canonical_version(x[0], args.release_type))
|
||||
for milestone, milestone_data in milestones_sorted:
|
||||
f.write(' - version: %s\n' % milestone)
|
||||
f.write(' projects:\n')
|
||||
for repo_short_name, sha in milestone_data:
|
||||
|
Loading…
x
Reference in New Issue
Block a user