Make compute-version.py return 0.0.0-commit as fallback

This commit is contained in:
Emil Lundberg 2017-12-11 12:56:55 +01:00
parent b53412ad03
commit 646f52e89d
No known key found for this signature in database
GPG Key ID: 1342CC2B5CF84F44

View File

@ -35,6 +35,7 @@ def compute_version(tag_prefix=None):
['git', 'describe',
'--tags',
'--dirty=-dirty',
'--always',
] + (
['--match=%s*' % tag_prefix] if tag_prefix else []
),
@ -72,6 +73,12 @@ def compute_version(tag_prefix=None):
git_version
)
# If version is raw abbreviated commit ID, prepend '0.0.0-'
git_version = re.sub(
r'^([0-9a-f]{7}(-dirty)?)$', r'0.0.0-\1',
git_version
)
return git_version