Files
medical-mall/get_logs.py

26 lines
724 B
Python

import subprocess
import os
import re
repos = [r"d:\骅锋\mall", r"d:\骅锋\医疗"]
output = []
for repo in repos:
if not os.path.exists(repo):
continue
os.chdir(repo)
# 使用 %B 获取原始提交信息,不进行转码
cmd = ["git", "log", "--since=2026-05-11 00:00:00", "--until=2026-05-15 23:59:59", "--pretty=format:COMMIT_START|%ai|%s", "--stat"]
res = subprocess.run(cmd, capture_output=True)
# 尝试用 utf-8 解码,如果失败则用 gbk
try:
text = res.stdout.decode("utf-8")
except:
text = res.stdout.decode("gbk", errors="replace")
output.append(f"--- REPOSITORY: {repo} ---\n" + text)
with open("repo_logs.txt", "w", encoding="utf-8") as f:
f.write("\n".join(output))