1
0
Fork 0
mirror of https://github.com/vofy/fekt-scara.git synced 2025-05-06 14:01:00 +02:00

Add commit hash to generated files

This commit is contained in:
Tomáš Batelka 2025-03-30 17:15:51 +02:00
parent 0834add188
commit e0452426fa
28 changed files with 5 additions and 1 deletions

View file

@ -1,6 +1,7 @@
#!/usr/bin/freecadcmd
import os
import subprocess
import FreeCAD as App # type: ignore
import Mesh # type: ignore
@ -13,6 +14,9 @@ project_root = os.path.abspath(
printed_cad_dir = os.path.join(project_root, "cad", "printed")
printed_3mf_dir = os.path.join(project_root, "3mf")
# Get the short hash of the current Git commit
git_short_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
# Create the 3mf directory if it doesn't exist
os.makedirs(printed_3mf_dir, exist_ok=True)
@ -41,7 +45,7 @@ for root, dirs, files in os.walk(printed_cad_dir):
output_path = os.path.join(
printed_3mf_dir,
os.path.relpath(root, printed_cad_dir),
f"{obj.Label}.3mf",
f"{obj.Label}_{git_short_hash}.3mf",
)
# Create the output directory if it doesn't already exist
os.makedirs(os.path.dirname(output_path), exist_ok=True)