From 06f39aa01becc1b24d1ee6c9eaf88fa2b288bb9a Mon Sep 17 00:00:00 2001 From: Jeffrey Hsu Date: Sun, 29 Jun 2025 02:26:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Git=20Hash=20=E5=88=B0?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E4=BF=A1=E6=81=AF=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/hook.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/hook.py b/utils/hook.py index 35fba99..5ea5035 100644 --- a/utils/hook.py +++ b/utils/hook.py @@ -1,10 +1,13 @@ +import subprocess from datetime import datetime -def gen_build_time(): +def gen_build_info(): + hash_str = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() with open('build_info.py', 'w', encoding='utf-8') as f: f.write(f"# Auto-generated build info\n") f.write(f"BUILD_TIME = '{datetime.now().isoformat(sep=' ', timespec='seconds')}'\n") + f.write(f"GIT_HASH = '{hash_str}'\n") -gen_build_time() +gen_build_info()