version.py 704 B

123456789101112131415161718192021222324252627282930
  1. import datetime
  2. import subprocess
  3. from functools import cache
  4. @cache
  5. def get_git_commit_unix_timestamp():
  6. return int(subprocess.check_output(["git", "show", "-s", "--format=%ct"]))
  7. @cache
  8. def get_fast_git_version_id():
  9. try:
  10. version = (
  11. subprocess.check_output(
  12. [
  13. "git",
  14. "describe",
  15. "--always",
  16. "--dirty",
  17. "--all",
  18. "--long",
  19. ]
  20. )
  21. .strip()
  22. .decode()
  23. )
  24. return (version, datetime.date.today())
  25. except Exception as e:
  26. print("Failed to check for git changes", e)