Skip to content

Commit

Permalink
update version.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Mar 9, 2016
1 parent bfe61de commit 9ed3d5e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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:
Expand Down

0 comments on commit 9ed3d5e

Please sign in to comment.