Files
ykxmz/_build/final_cleanup.py
xmz7891 e29b741ddf 收尾:CHANGELOG 补 1.7.1 + 清历史产物 + 修验证脚本路径
- _build/CHANGELOG.md 补上 1.7.1 条目(发版说明的唯一来源)
- 两个验证脚本还在用旧的管理页路径 zhingzhuanzhan,
  跑起来会误报失败,改成 zhongzhuanzhan
- dist 里清掉 1.6.x 的历史产物(Gitee 发行版里有,删了能下回来)
2026-10-07 00:17:55 +08:00

114 lines
3.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
r'''收尾清理:
1. 两个验证脚本还在用旧的管理页路径,跑起来会误报失败
2. dist 里堆着 1.6.x 的历史产物(Gitee 发行版里都有,删了也能下回来)
3. 把改动提交
'''
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
GIT = r"C:\Program Files\Git\bin\git.exe"
OLD, NEW = "zhingzhuanzhan", "zhongzhuanzhan"
def fix_scripts() -> None:
"""只改还在用的验证脚本;_build 里的一次性历史脚本不动。"""
print(" 一、修还在用的验证脚本")
for name in ("check_web.sh", "final_web_check.sh", "verify_site_admin.sh"):
path = ROOT / "_build" / name
if not path.is_file():
continue
text = path.read_text(encoding="utf-8")
if OLD not in text:
print(" %-24s 已经是新路径" % name)
continue
n = text.count(OLD)
path.write_text(text.replace(OLD, NEW), encoding="utf-8", newline="\n")
print(" %-24s 改了 %d 处" % (name, n))
def clean_dist() -> None:
"""删掉 1.6.x 的历史产物。"""
print()
print(" 二、清理 dist 里的历史版本")
dist = ROOT / "dist"
if not dist.is_dir():
print(" dist 不存在")
return
removed = []
for path in sorted(dist.iterdir()):
if not path.is_file():
continue
# 保留 1.7.x
if "1.7." in path.name:
continue
if any(tag in path.name for tag in ("1.6.0", "1.6.1", "1.6.2")):
path.unlink()
removed.append(path.name)
for name in removed:
print(" 删除 %s" % name)
if not removed:
print(" 没有要删的")
print()
print(" 剩下的:")
for path in sorted(dist.iterdir()):
if path.is_file():
print(" %-34s %6.2f MB"
% (path.name, path.stat().st_size / 1024 / 1024))
def commit() -> None:
print()
print(" 三、提交")
subprocess.run([GIT, "add", "-A"], cwd=str(ROOT), check=False)
message = (
"收尾:CHANGELOG 补 1.7.1 + 清历史产物 + 修验证脚本路径\n"
"\n"
"- _build/CHANGELOG.md 补上 1.7.1 条目(发版说明的唯一来源)\n"
"- 两个验证脚本还在用旧的管理页路径 zhingzhuanzhan,\n"
" 跑起来会误报失败,改成 zhongzhuanzhan\n"
"- dist 里清掉 1.6.x 的历史产物(Gitee 发行版里有,删了能下回来)\n"
)
msg_file = ROOT / "_build" / "_cmsg.txt"
msg_file.write_bytes(message.encode("utf-8"))
result = subprocess.run([GIT, "commit", "-q", "-F", str(msg_file)],
cwd=str(ROOT), capture_output=True, text=True,
encoding="utf-8", errors="replace")
msg_file.unlink(missing_ok=True)
print(" commit exit=%s" % result.returncode)
if result.returncode != 0 and result.stdout:
print(" " + result.stdout.strip()[:200])
show = subprocess.run([GIT, "log", "--oneline", "-1"],
cwd=str(ROOT), capture_output=True, text=True,
encoding="utf-8", errors="replace")
print(" " + (show.stdout or "").strip())
env_push = {"GIT_SSH_COMMAND": r'"C:\Program Files\Git\usr\bin\ssh.exe"'}
import os
push_env = dict(os.environ)
push_env.update(env_push)
push = subprocess.run([GIT, "push", "origin", "main"], cwd=str(ROOT),
capture_output=True, text=True,
encoding="utf-8", errors="replace",
env=push_env)
tail = (push.stderr or push.stdout or "").strip().splitlines()[-2:]
for line in tail:
print(" " + line)
def main() -> int:
fix_scripts()
clean_dist()
commit()
return 0
if __name__ == "__main__":
sys.exit(main())