From 4f2d42e74ad6f26dbe4e494edbcc31c9e9abcc27 Mon Sep 17 00:00:00 2001 From: Overwatch Date: Wed, 20 Aug 2014 11:09:27 +0200 Subject: [PATCH] added automatic version stamping --- deploy-versioning.sh | 9 +++++++++ over-video.py | 5 +++-- version-tool.py | 20 ++++++++++++++++++++ version.py | 4 ++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 deploy-versioning.sh create mode 100755 version-tool.py create mode 100644 version.py diff --git a/deploy-versioning.sh b/deploy-versioning.sh new file mode 100755 index 0000000..e84eee8 --- /dev/null +++ b/deploy-versioning.sh @@ -0,0 +1,9 @@ +#! /bin/bash +# encoding: utf-8 + +echo "version.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)" +echo '#! /bin/bash\n\nexec git checkout HEAD -- version.py' > .git/hooks/post-commit +chmod +x .git/hooks/post-commit diff --git a/over-video.py b/over-video.py index 4e33b8c..3f9868b 100755 --- a/over-video.py +++ b/over-video.py @@ -11,13 +11,14 @@ import tempfile import time from aux import Command, parse_fps +from version import _version # -------------------------------------------------- prefix = over.core.textui.prefix _print = over.core.textui.Output('over.video') -# -------------------------------------------------- TODO Raw -filter:v interface for resizing and so on +# -------------------------------------------------- command = over.core.types.ndict() command.identify = Command('ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', 'INFILE') @@ -31,7 +32,7 @@ command.vfilter = Command('-filter:v', 'ARGS') # -------------------------------------------------- if __name__ == '__main__': - main = over.core.app.Main('Over-Video', '0.1', 'AWARE-Overwatch Joint Software License', '~/.over/video.cfg') + main = over.core.app.Main('Over-Video', "%d (%s)" %_version, 'AWARE-Overwatch Joint Software License', '~/.over/video.cfg') main.add_option('profile', 'str', 'x264', 'Encoding profile to use. Available are either §mtheora§/ for Theora and Vorbis in an Ogg container, §mx264§/ for H.264 and Vorbis in a Matroska container, or §mwav§/ which just extracts audio into a wav for further processing.') main.add_option('video-quality', 'float', 22, 'Video encoding quality. Use 0-10 for Theora (0 being the lowest, 5-7 is generally watchable) and 0-51 for x264 (0 being lossless, 18-28 is reasonable).', short_name='v') main.add_option('audio-quality', 'float', 2, 'Audio encoding quality with -1 being the worst and 10 being the best.', short_name='a') diff --git a/version-tool.py b/version-tool.py new file mode 100755 index 0000000..dd13bfc --- /dev/null +++ b/version-tool.py @@ -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) diff --git a/version.py b/version.py new file mode 100644 index 0000000..91b177c --- /dev/null +++ b/version.py @@ -0,0 +1,4 @@ +#! /bin/env python3 +# encoding: utf-8 + +_version = (0, '00000000') # OVER_VERSION_IDENTIFIER