From 87285cfcaaeae07b1bfa00e15e226a2616c4a960 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 20 Sep 2024 22:04:25 +0200 Subject: [PATCH] Add support for using other rev than HEAD in git-ref.py. --- extra/git-ref.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extra/git-ref.py b/extra/git-ref.py index fa384fa3..5eef8654 100644 --- a/extra/git-ref.py +++ b/extra/git-ref.py @@ -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"