git version

This commit is contained in:
oh3bsg 2023-11-11 13:00:06 +02:00
parent d28f5dff30
commit 978789bdb5
2 changed files with 40 additions and 0 deletions

33
git_version.py Normal file
View File

@ -0,0 +1,33 @@
import sys
from io import StringIO
import subprocess
# Redirect stdout to an in-memory buffer
result_buffer = StringIO()
sys.stdout = result_buffer
subprocess.run(["git", "describe", "--abbrev=6", "--dirty", "--always", "--tags"])
# Get the captured output
git_version = result_buffer.getvalue()
# Restore stdout
sys.stdout = sys.__stdout__
'''
import sys
from io import StringIO
# Redirect stdout to an in-memory buffer
result_buffer = StringIO()
sys.stdout = result_buffer
# Print something
print("This is a test")
# Get the captured output
captured_output = result_buffer.getvalue()
# Restore stdout
sys.stdout = sys.__stdout__
'''

View File

@ -36,6 +36,12 @@ lib_deps =
paulstoffregen/Time@^1.6.0
lib_ignore = Time
;extra_scripts = git_version.py
build_flags =
-DGIT_VERSION git_version
; Add / remove the following two lines for separate fonts partition in flash
; after changes:
; - pio run --target=upload (uploads partition table)
@ -45,5 +51,6 @@ lib_ignore = Time
; Then everything should be "back to normal"
;
extra_scripts = post:scripts/makefontpartition.py
git_version.py
;board_build.partitions = partition-fonts.csv