KEK/ESP32/prepare.py
folkert van heusden 21558d7383
git version
2024-04-11 16:49:26 +02:00

17 lines
463 B
Python
Executable file

#! /usr/bin/python3
import json
import subprocess
import sys
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()