添加 Git Hash 到构建信息中
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
|
import subprocess
|
||||||
from datetime import datetime
|
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:
|
with open('build_info.py', 'w', encoding='utf-8') as f:
|
||||||
f.write(f"# Auto-generated build info\n")
|
f.write(f"# Auto-generated build info\n")
|
||||||
f.write(f"BUILD_TIME = '{datetime.now().isoformat(sep=' ', timespec='seconds')}'\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()
|
||||||
|
|||||||
Reference in New Issue
Block a user