properly support private builds in the registry

when building snapshots, maven will sometimes add some information
*after* the -SNAPSHOT like this:
 1.4.6-SNAPSHOT (private-0986edd9-egolov)

the old registry code would transform this to
 1.4.6.preview (private-0986edd9-egolov)
which is not a valid version string for pkg_resources.

strip everything after the -SNAPSHOT tag and thus produce a clean
version string that is comparable properly

Change-Id: I765c991ac7632b3c76f548112d2a5323a8ce4489
Signed-off-by: Evgeni Golov <evgeni@golov.de>
This commit is contained in:
Evgeni Golov 2017-04-28 11:20:04 +02:00
parent 870045688b
commit 430f1b4694
2 changed files with 5 additions and 1 deletions

View File

@ -64,7 +64,7 @@ class ModuleRegistry(object):
mapped to its plugin info dictionary.
"""
version = plugin_info.get('version', '0')
plugin_info['version'] = re.sub(r'(.*)-(?:SNAPSHOT|BETA)',
plugin_info['version'] = re.sub(r'(.*)-(?:SNAPSHOT|BETA).*',
r'\g<1>.preview', version)
aliases = []

View File

@ -24,6 +24,10 @@ class ModuleRegistryPluginInfoTestsWithScenarios(
('s11', dict(v1='1.0.preview', op='__lt__', v2='1.0')),
('s12', dict(v1='1.1-SNAPSHOT', op='__gt__', v2='1.0')),
('s13', dict(v1='1.0a-SNAPSHOT', op='__lt__', v2='1.0a')),
('s14', dict(v1='1.4.6-SNAPSHOT (private-0986edd9-example)',
op='__lt__', v2='1.4.6')),
('s15', dict(v1='1.4.6-SNAPSHOT (private-0986edd9-example)',
op='__gt__', v2='1.4.5')),
]
def setUp(self):