Merge ~blake-rouse/maas:fix-1772679 into maas:master

Proposed by Blake Rouse on 2018-05-22
Status: Merged
Approved by: Blake Rouse on 2018-05-23
Approved revision: 992bd25f204c4f28dd1974d8ac50cbf1035778d5
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~blake-rouse/maas:fix-1772679
Merge into: maas:master
Diff against target: 47 lines (+12/-5)
2 files modified
src/provisioningserver/utils/tests/test_version.py (+6/-0)
src/provisioningserver/utils/version.py (+6/-5)
Reviewer Review Type Date Requested Status
MAAS Lander Approve on 2018-05-22
Newell Jensen (community) 2018-05-22 Approve on 2018-05-22
Review via email: mp+346650@code.launchpad.net

Commit message

LP: #1772679 - Fix version handling for +revno on minor version and .g for git revision.

To post a comment you must log in.
Newell Jensen (newell-jensen) wrote :

LGTM

review: Approve
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix-1772679 lp:~blake-rouse/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 992bd25f204c4f28dd1974d8ac50cbf1035778d5

review: Approve
Blake Rouse (blake-rouse) wrote :

I have ran this in the CI, hit no issues. It still running but passed the part where this would cause any issues.

http://162.213.35.104:8080/job/maas-git-manual/240/console

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/utils/tests/test_version.py b/src/provisioningserver/utils/tests/test_version.py
2index 0efd3d9..62cc686 100644
3--- a/src/provisioningserver/utils/tests/test_version.py
4+++ b/src/provisioningserver/utils/tests/test_version.py
5@@ -188,6 +188,12 @@ class TestGetVersionTuple(MAASTestCase):
6 2, 3, 5, 0, 5, 0, '1', '2x.x3.x5x~alpha5Y', 'xxx-g1',
7 'alphaY', False)
8 }),
9+ ('ci version', {
10+ 'version': '2.4.0+6981.g011e51b+ci-0ubuntu1',
11+ 'expected_tuple': (
12+ 2, 4, 0, 0, 0, 6981, '011e51b', '2.4.0',
13+ '6981.g011e51b+ci-0ubuntu1', None, False)
14+ }),
15 )
16
17 def test__returns_expected_tuple(self):
18diff --git a/src/provisioningserver/utils/version.py b/src/provisioningserver/utils/version.py
19index 3f78f08..e4f6afd 100644
20--- a/src/provisioningserver/utils/version.py
21+++ b/src/provisioningserver/utils/version.py
22@@ -135,9 +135,9 @@ def _coerce_to_int(string: str) -> int:
23
24
25 def get_version_tuple(maas_version: str) -> MAASVersion:
26- version_parts = maas_version.split('-', 1)
27+ version_parts = re.split(r'[-|+]', maas_version, 1)
28 short_version = version_parts[0]
29- major_minor_point = re.sub(r'~.*', '', short_version).split('.')
30+ major_minor_point = re.sub(r'~.*', '', short_version).split('.', 2)
31 for i in range(3):
32 try:
33 major_minor_point[i] = _coerce_to_int(major_minor_point[i])
34@@ -167,9 +167,10 @@ def get_version_tuple(maas_version: str) -> MAASVersion:
35 qualifier_type_version = qualifier_types.get(qualifier_type, 0)
36 revno = 0
37 git_rev = ''
38- # If we find a '-g', that means the extended info indicates a git revision.
39- if '-g' in extended_info:
40- revno, git_rev = extended_info.split('-')[0:2]
41+ # If we find a '-g' or '.g', that means the extended info indicates a
42+ # git revision.
43+ if '-g' in extended_info or '.g' in extended_info:
44+ revno, git_rev = re.split(r'[-|.|+]', extended_info)[0:2]
45 # Strip any non-numeric characters from the revno, just in case.
46 revno = _coerce_to_int(revno)
47 # Remove anything that doesn't look like a hexadecimal character.

Subscribers

People subscribed via source and target branches