2026-05-02 12:52:32 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# vim: ft=python
|
|
|
|
|
# -*- mode: python -*-
|
|
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
def is_arg_set(name):
|
|
|
|
|
for arg in sys.argv:
|
|
|
|
|
if arg == '--{}'.format(name):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_arg(name):
|
|
|
|
|
ret_next = False
|
|
|
|
|
for arg in sys.argv:
|
|
|
|
|
if ret_next:
|
|
|
|
|
return arg
|
|
|
|
|
|
|
|
|
|
if arg == '--{}'.format(name):
|
|
|
|
|
ret_next = True
|
|
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
2026-05-31 17:33:02 +01:00
|
|
|
source_dir = get_arg('source-dir')
|
|
|
|
|
current_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0'], cwd=source_dir).decode('utf-8').strip()
|
2026-05-02 12:52:32 +01:00
|
|
|
|
|
|
|
|
build_id = '{}'.format(current_tag)
|
|
|
|
|
|
|
|
|
|
if sys.stdout.isatty():
|
|
|
|
|
print('{}'.format(build_id))
|
|
|
|
|
else:
|
|
|
|
|
print('{}'.format(build_id), end='')
|