blob: 8f766dad76535456acade2e0fab86b0803a4877b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import os
import subprocess
def get_git_cmd_output(cmd):
script_dir = os.path.dirname(os.path.abspath(__file__))
p = subprocess.run(['git', '-C', script_dir] + cmd, check=True,
capture_output=True)
return p.stdout.decode('ascii').strip()
def get_fw_version():
version_value = None
try:
git_hash = get_git_cmd_output(['rev-parse', '--short=10', 'HEAD'])
git_count = get_git_cmd_output(['rev-list', '--all', '--count'])
version_value = f'{git_hash}-{git_count}'
except:
pass
return version_value
|