From 9ed3d5ed5e1ee376ce43789adaf4e9c518c65d09 Mon Sep 17 00:00:00 2001 From: Changaco Date: Wed, 9 Mar 2016 17:43:10 +0100 Subject: [PATCH] update `version.py` --- version.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/version.py b/version.py index 2e5de33..9e02db9 100644 --- a/version.py +++ b/version.py @@ -4,9 +4,10 @@ import re from subprocess import CalledProcessError, check_output -__all__ = ('get_version') -tag_re = re.compile(r'\btag: ([0-9][^,]*)\b') +PREFIX = '' + +tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX) version_re = re.compile('^Version: (.+)$', re.M) @@ -20,18 +21,16 @@ def get_version(): if isdir(join(d, '.git')): # Get the version using "git describe". - cmd = 'git describe --tags --match [0-9]* --dirty'.split() + cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX try: - version = check_output(cmd).decode().strip() + version = check_output(cmd.split()).decode().strip()[len(PREFIX):] except CalledProcessError: - print('Unable to get version number from git tags') - exit(1) + raise RuntimeError('Unable to get version number from git tags') # PEP 440 compatibility if '-' in version: if version.endswith('-dirty'): - print('The working tree is dirty') - exit(1) + raise RuntimeError('The working tree is dirty') version = '.post'.join(version.split('-')[:2]) else: