Fixed the generation of the version string

This commit is contained in:
Tomas Groth 2019-09-13 18:48:30 +02:00
parent 1f813bcaf3
commit a1ea10721f
1 changed files with 6 additions and 5 deletions

View File

@ -318,15 +318,16 @@ class Builder(object):
else:
# This is a development build, get the tag and revision
output = self._git('tag', self.branch_path, ['--list'], err_msg='Error running git tag')
lines = output.splitlines()
lines = output.strip().splitlines()
if len(lines) == 0:
tag = '0.0.0'
else:
tmp, ref_tag = lines[-1].split()
tag = ref_tag.split('/')[2]
revision = self._git('rev-list', self.branch_path, ['--count', 'HEAD'], 'Error running git rev-list')
tag = lines[-1]
revision_count = self._git('rev-list', self.branch_path, ['--count', 'HEAD'], 'Error running git rev-list')
revision_count = revision_count.strip()
sha = self._git('rev-parse', self.branch_path, ['--short', 'HEAD'], 'Error running git rev-parse')
self.version = '{tag}.git-{revision}-{sha}'.format(tag=tag, revision=revision, sha=sha)
sha = sha.strip()
self.version = '{tag}.git-r{revision}-{sha}'.format(tag=tag, revision=revision_count, sha=sha)
# Write the version to the version file
with open(os.path.join(self.dist_path, '.version'), 'w') as version_file:
version_file.write(str(self.version))