added automatic version stamping

This commit is contained in:
Overwatch 2014-08-20 11:09:27 +02:00
parent 0fb3276b9f
commit 4f2d42e74a
4 changed files with 36 additions and 2 deletions

9
deploy-versioning.sh Executable file
View file

@ -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

View file

@ -11,13 +11,14 @@ import tempfile
import time import time
from aux import Command, parse_fps from aux import Command, parse_fps
from version import _version
# -------------------------------------------------- # --------------------------------------------------
prefix = over.core.textui.prefix prefix = over.core.textui.prefix
_print = over.core.textui.Output('over.video') _print = over.core.textui.Output('over.video')
# -------------------------------------------------- TODO Raw -filter:v interface for resizing and so on # --------------------------------------------------
command = over.core.types.ndict() command = over.core.types.ndict()
command.identify = Command('ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', 'INFILE') 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__': 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('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('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') main.add_option('audio-quality', 'float', 2, 'Audio encoding quality with -1 being the worst and 10 being the best.', short_name='a')

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)

4
version.py Normal file
View file

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