From afcc047ee3e4cfd96272513198b4f46b2f38bfe6 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 12 Jul 2018 21:41:00 +0200 Subject: [PATCH] Add an option for providing tag and revision to avoid using bzr. --- builders/builder.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/builders/builder.py b/builders/builder.py index 6aec400..9670c69 100644 --- a/builders/builder.py +++ b/builders/builder.py @@ -160,6 +160,8 @@ class Builder(object): parser.add_argument('--skip-translations', action='store_true', default=False, help='Do NOT update the language translation files') parser.add_argument('--debug', action='store_true', default=False, help='Create a debug build') + parser.add_argument('--tag-override', metavar='-bzr', default=None, + help='Override tag and revision, should be in format -bzr') self.add_extra_args(parser) self.args = parser.parse_args() @@ -297,17 +299,20 @@ class Builder(object): """ self._print('Writing version file...') if not self.args.release: - # This is a development build, get the tag and revision - output = self._bzr('tags', self.branch_path, err_msg='Error running bzr tags') - lines = output.splitlines() - if len(lines) == 0: - tag = '0.0.0' - revision = '0' + if self.args.tag_override: + self.version = self.args.tag_override else: - tag, revision = lines[-1].split() - output = self._bzr('log', self.branch_path, ['--line', '-r', '-1'], 'Error running bzr log') - revision = output.split(':')[0] - self.version = '{tag}-bzr{revision}'.format(tag=tag, revision=revision) + # This is a development build, get the tag and revision + output = self._bzr('tags', self.branch_path, err_msg='Error running bzr tags') + lines = output.splitlines() + if len(lines) == 0: + tag = '0.0.0' + revision = '0' + else: + tag, revision = lines[-1].split() + output = self._bzr('log', self.branch_path, ['--line', '-r', '-1'], 'Error running bzr log') + revision = output.split(':')[0] + self.version = '{tag}-bzr{revision}'.format(tag=tag, revision=revision) # 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))