From a8be0127a417d4c19c9f898f7eeae8c4ce859d23 Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Fri, 25 Jul 2025 21:29:58 +0800 Subject: [PATCH] chore(log): add repo git commit log --- main.py | 18 ++++++++++++++++++ requirements.txt | Bin 0 -> 438 bytes 2 files changed, 18 insertions(+) create mode 100644 requirements.txt diff --git a/main.py b/main.py index 53201b2..0de8fce 100644 --- a/main.py +++ b/main.py @@ -30,6 +30,7 @@ import json from pathlib import Path from datetime import datetime, date from typing import Dict, Any, Optional, Tuple, List +import git import mexc_spot_v3 @@ -483,15 +484,32 @@ class TradingConfig: return today_trades +def git_commit(repo_path: str = ".") -> str: + """获取Git仓库版本""" + + try: + repo = git.Repo(repo_path) + return repo.head.commit.hexsha + except Exception as _: + return None def main(): """主函数""" + logger.info("=" * 40) + # 获取主程序Git仓库版本 + app_commit = git_commit(".")[:10] + # 确保config目录存在 if not os.path.exists("config"): logger.error("配置目录 config 不存在") return + # 获取config, output仓库版本 + config_commit = git_commit("config")[:10] + output_commit = git_commit("output")[:10] + logger.info("主程序 %s, 配置 %s, 输出 %s", app_commit, config_commit, output_commit) + # 获取config目录下所有json文件 config_files = list(Path("config").glob("*.json")) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..22cb36870073fab34c9cdef0d5f6e48d851268f3 GIT binary patch literal 438 zcmYk3%}&Bl5QWd$#7BX&rD|NbcIztutwK_n?)jNBr{7;&jXJ4n zuV?0gU#Et-(NcFzt6tZ-(pEdIVHWsR3mx>vzgONSbf0z!^$JbTbXL89RSnwMIo=z4 zCi-afNgr@__#Mm&hnDHd5S#bxjx8hj;0&?n7Dh6YGk~ry^o_Oih4;ehiqF~iPG)!b z+%u7DCPM*B?Fr@)?&!Dj$6j$;q>H_UbniwYaqGrXUFas-nT