From 2075fe64b9d3790df614a00b7484a19b1af8f4e4 Mon Sep 17 00:00:00 2001 From: lidf Date: Wed, 1 Jul 2026 15:27:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20health.py=20=5Fget=5Fvendor=5Fcommit=20?= =?UTF-8?q?=E5=8F=AA=E8=BF=94=E5=9B=9E=20commit=20hash=20=E8=80=8C?= =?UTF-8?q?=E9=9D=9E=E6=95=B4=E4=B8=AA=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VENDOR_COMMIT 是多行标记文件(source/commit/date), 旧逻辑 f.read().strip() 返回整个文件内容导致 health 输出污染。 对齐 cli.py 的逐行 commit: 前缀解析逻辑。 --- mindcli/health.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mindcli/health.py b/mindcli/health.py index 679fbde..ce35aaa 100644 --- a/mindcli/health.py +++ b/mindcli/health.py @@ -261,10 +261,18 @@ class _ThreadedHTTPServer(ThreadingMixIn, HTTPServer): def _get_vendor_commit() -> str: + """读取 _vendor/VENDOR_COMMIT 文件,提取 commit hash。 + + VENDOR_COMMIT 是多行标记文件(# 注释 + source:/commit:/date:), + 只返回 commit: 行的值,不是整个文件内容。 + """ commit_file = os.path.join(mindcli._VENDOR_DIR, "VENDOR_COMMIT") try: with open(commit_file) as f: - return f.read().strip() + for line in f: + if line.startswith("commit:"): + return line.split(":", 1)[1].strip() + return "unknown" except FileNotFoundError: return "unknown"