Add support for using other rev than HEAD in git-ref.py.

This commit is contained in:
Bartosz Taudul 2024-09-20 22:04:25 +02:00
parent 821f2f907b
commit 87285cfcaa
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -2,13 +2,19 @@
import filecmp
import subprocess
import sys
import os
out = "GitRef.hpp"
tmp = f"{out}.tmp"
if len(sys.argv) > 1:
rev = sys.argv[1]
else:
rev = "HEAD"
try:
ref = subprocess.run(["git", "rev-parse", "--short", "HEAD"], check=True, capture_output=True).stdout.decode().strip()
ref = subprocess.run(["git", "rev-parse", "--short", rev], check=True, capture_output=True).stdout.decode().strip()
except subprocess.CalledProcessError:
ref = "unknown"