KEK/ESP32/prepare.py
folkert van heusden f80b2244ef
unused imports
2024-04-28 22:44:32 +02:00

16 lines
441 B
Python
Executable file

#! /usr/bin/python3
import subprocess
def get_git_hash():
ret = subprocess.run(["git", "diff", "--quiet"], stdout=subprocess.PIPE, text=True)
add = '*' if ret.returncode != 0 else ''
ret = subprocess.run(["git", "rev-parse", "--short", "HEAD"], stdout=subprocess.PIPE, text=True)
return ret.stdout.strip() + add
fh = open('version.cpp', 'w')
fh.write('const char *version_str = "' + get_git_hash() + '";\n')
fh.close()