Revision 9b0839dd
b/devflow/versioning.py | ||
---|---|---|
73 | 73 |
f.close() |
74 | 74 |
return lines[0] |
75 | 75 |
|
76 |
def validate_version(base_version, vcs_info): |
|
77 |
branch = vcs_info.branch |
|
78 |
|
|
79 |
brnorm = utils.normalize_branch_name(branch) |
|
80 |
btypestr = utils.get_branch_type(branch) |
|
81 |
|
|
82 |
try: |
|
83 |
btype = BRANCH_TYPES[btypestr] |
|
84 |
except KeyError: |
|
85 |
allowed_branches = ", ".join(x for x in BRANCH_TYPES.keys()) |
|
86 |
raise ValueError("Malformed branch name '%s', cannot classify as one " |
|
87 |
"of %s" % (btypestr, allowed_branches)) |
|
88 |
|
|
89 |
if btype.versioned: |
|
90 |
try: |
|
91 |
bverstr = brnorm.split("-")[1] |
|
92 |
except IndexError: |
|
93 |
# No version |
|
94 |
raise ValueError("Branch name '%s' should contain version" % |
|
95 |
branch) |
|
96 |
|
|
97 |
# Check that version is well-formed |
|
98 |
if not re.match(VERSION_RE, bverstr): |
|
99 |
raise ValueError("Malformed version '%s' in branch name '%s'" % |
|
100 |
(bverstr, branch)) |
|
101 |
|
|
102 |
m = re.match(btype.allowed_version_re, base_version) |
|
103 |
if not m or (btype.versioned and m.groupdict()["bverstr"] != bverstr): |
|
104 |
raise ValueError("Base version '%s' unsuitable for branch name '%s'" % |
|
105 |
(base_version, branch)) |
|
76 | 106 |
|
77 | 107 |
def python_version(base_version, vcs_info, mode): |
78 | 108 |
"""Generate a Python distribution version following devtools conventions. |
... | ... | |
191 | 221 |
|
192 | 222 |
|
193 | 223 |
""" |
194 |
|
|
224 |
validate_version(base_version, vcs_info) |
|
195 | 225 |
branch = vcs_info.branch |
196 |
|
|
197 |
brnorm = utils.normalize_branch_name(branch) |
|
198 | 226 |
btypestr = utils.get_branch_type(branch) |
199 |
|
|
200 |
try: |
|
201 |
btype = BRANCH_TYPES[btypestr] |
|
202 |
except KeyError: |
|
203 |
allowed_branches = ", ".join(x for x in BRANCH_TYPES.keys()) |
|
204 |
raise ValueError("Malformed branch name '%s', cannot classify as one " |
|
205 |
"of %s" % (btypestr, allowed_branches)) |
|
206 |
|
|
207 |
if btype.versioned: |
|
208 |
try: |
|
209 |
bverstr = brnorm.split("-")[1] |
|
210 |
except IndexError: |
|
211 |
# No version |
|
212 |
raise ValueError("Branch name '%s' should contain version" % |
|
213 |
branch) |
|
214 |
|
|
215 |
# Check that version is well-formed |
|
216 |
if not re.match(VERSION_RE, bverstr): |
|
217 |
raise ValueError("Malformed version '%s' in branch name '%s'" % |
|
218 |
(bverstr, branch)) |
|
219 |
|
|
220 |
m = re.match(btype.allowed_version_re, base_version) |
|
221 |
if not m or (btype.versioned and m.groupdict()["bverstr"] != bverstr): |
|
222 |
raise ValueError("Base version '%s' unsuitable for branch name '%s'" % |
|
223 |
(base_version, branch)) |
|
227 |
#this cannot fail |
|
228 |
btype = BRANCH_TYPES[btypestr] |
|
224 | 229 |
|
225 | 230 |
if mode not in ["snapshot", "release"]: |
226 | 231 |
raise ValueError("Specified mode '%s' should be one of 'snapshot' or " |
Also available in: Unified diff