automatic version stamping implemented (using git filters)

This commit is contained in:
Overwatch 2014-08-17 21:39:40 +02:00
parent 5e655c8e06
commit 5e986b4957
4 changed files with 30 additions and 3 deletions

View file

@ -6,7 +6,7 @@ import re
from . import file
from . import textui
from ..version import _revision
from ..version import _version
prefix = textui.prefix
@ -73,7 +73,7 @@ def _print_help(main, help_texts, chapter=None, list_options=False):
# dirty as fuck :-)
if not chapter and not main.version is None:
if help_texts == _over_help_texts:
_output(">>> §yover.core§/ version §y%d§/ (%s), licensed under the §yAO-JSL§/" %_revision, newlines=2)
_output(">>> §yover.core§/ version §y%d§/ (%s), licensed under the §yAO-JSL§/" %_version, newlines=2)
else:
_output("§y%s§/ version §y%s§/, licensed under the §y%s§/" %(main.name, main.version, main.license), newlines=2)

7
deploy-versioning.sh Executable file
View file

@ -0,0 +1,7 @@
#! /bin/bash
# encoding: utf-8
echo "*.py filter=version" >> .git/info/attributes
ln -fs ../version-tool.py .git/version-tool.py
git config --local filter.version.clean="python3 ./.git/version-tool.py --clean"
git config --local filter.version.smudge="python3 ./.git/version-tool.py --set $(git rev-list HEAD --count) $(git rev-parse HEAD)"

20
version-tool.py Executable file
View file

@ -0,0 +1,20 @@
#! /bin/env python3
# encoding: utf-8
import re
import sys
REPLACEMENT = "_version = (%s, '%s') # OVER_VERSION_IDENTIFIER"
MARKER = "_version = \((\d+), '([0-9a-f]{8})'\) # OVER_VERSION_IDENTIFIER"
SUBMARKER = 'OVER_VERSION_IDENTIFIER'
if __name__ == "__main__":
action = sys.argv[1]
data = (sys.argv[2], sys.argv[3][:8]) if action == "--set" else ('0', '00000000')
for line in sys.stdin.readlines():
if SUBMARKER in line:
if re.match(MARKER, line):
line = re.sub(MARKER, REPLACEMENT %data, line)
sys.stdout.write(line)

View file

@ -1,4 +1,4 @@
#! /bin/env python3
# encoding: utf-8
_revision = (0, '00000000') # GIT_REVISION_IDENTIFIER
_version = (0, '00000000') # OVER_VERSION_IDENTIFIER