Add support for a VERSION file to compute-version.py

This commit is contained in:
Emil Lundberg 2017-11-27 16:17:49 +01:00
parent 693db090c8
commit 418be35e10
No known key found for this signature in database
GPG Key ID: 1342CC2B5CF84F44
2 changed files with 20 additions and 3 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ yubioath-desktop.app/
.ropeproject
Makefile*
/VERSION
moc_*.cpp
moc_*.h
qrc_*.cpp

22
compute-version.py Normal file → Executable file
View File

@ -23,6 +23,8 @@
# - If the "-dirty" suffix was present, append ".0".
# - If the "-dirty" suffix was not present, append ".1".
import argparse
import os
import re
import subprocess
import sys
@ -74,6 +76,20 @@ def compute_version(tag_prefix=None):
if __name__ == '__main__':
print(compute_version(
tag_prefix=sys.argv[1] if len(sys.argv) > 1 else None
))
parser = argparse.ArgumentParser(
description='Compute version number from Git tags',
add_help=True
)
parser.add_argument('-f', '--version-file',
action='store', dest='version_file',
help='Read version from VERSION_FILE if it exists')
parser.add_argument('tag_prefix',
action='store',
help='Prefix for git tags eligible as version tags')
args = parser.parse_args()
if args.version_file is not None and os.path.isfile(args.version_file):
with open(args.version_file) as f:
sys.stdout.write(f.read())
else:
print(compute_version(tag_prefix=args.tag_prefix))