non-version tags don't break the build

This commit is contained in:
jobevers 2017-02-22 14:54:09 -06:00
parent d1c308181b
commit 26f5d08567

View file

@ -16,16 +16,26 @@ def main():
version = args.version
else:
tag = subprocess.check_output(['git', 'describe']).strip()
version = get_version_from_tag(tag)
try:
version = get_version_from_tag(tag)
except InvalidVersionTag:
# this should be an error but its easier to handle here
# than in the calling scripts.
print 'Tag cannot be converted to a version, Exitting'
return
set_version(version)
class InvalidVersionTag(Exception):
pass
def get_version_from_tag(tag):
match = re.match('v([\d.]+)', tag)
if match:
return match.group(1)
else:
raise Exception('Failed to parse version from tag {}'.format(tag))
raise InvalidVersionTag('Failed to parse version from tag {}'.format(tag))
def set_version(version):