Skip to content

P0: 系统性修复 Windows 整合包更新机制 #57

@wochenlong

Description

@wochenlong

背景

Windows Portable 7z 的更新机制已经多次在发版中回归,影响面大且用户无法自救,应定义为 P0。

近期 v2.5.3 暴露的问题:

  • Update-SD-Trainer.bat 提示 This portable package is not a git checkout,说明发布包内 SD-Trainer/.git 缺失。
  • update/update_sd_trainer.bat 曾由打包脚本生成裸 git pull,没有复用根目录健壮更新器。
  • 纯 7z 用户、Git 版整合包用户、源码用户路径容易混淆,Release 说明和包内 README 不足以防止误用。
  • 更新后根目录 launcher、子模块/内置标签编辑器、用户数据保护等都依赖人工 checklist,容易漏。

v2.6.0 已做一轮止血:

  • build_portable.ps1 自动嵌入 shallow .gitSD-Trainer/.git
  • update/update_sd_trainer.bat 转调根目录 Update-SD-Trainer.bat
  • 打包前校验 mikazuki/dataset-tag-editor/scripts/launch.py
  • 新增 tests/test_portable_packaging_scripts.py 覆盖部分规则。

但这还不是系统性解决,需要把“可更新整合包”变成强门禁,而不是靠人工记忆。

目标

建立 Portable 更新机制的 P0 发布门禁,确保每次 7z 发出前自动证明:

  • 新包内 SD-Trainer/.git/HEAD 存在,且是 shallow git checkout。
  • git remote -v 指向 https://github.com/wochenlong/lora-scripts-next.git
  • Update-SD-Trainer.bat 能在包内识别当前分支并执行 fetch/ff-only 更新流程。
  • update/update_sd_trainer.bat 只是转调根 Update-SD-Trainer.bat,不得再出现裸 git pull
  • 更新后会刷新根目录 run_gui.bat / run_gui_portable.bat
  • 用户数据目录不会被覆盖:sd-models/output/logs/huggingface/train/config/toml/autosave/assets/config.jsonconfig/.update_cache.jsonsd-trainer-log.txt
  • .git 的旧包必须明确失败并引导下载新 Release,不能显示“更新完成”。

建议任务

  1. build/test_portable_release.ps1 正式纳入仓库或迁到 scripts/portable/ 下,避免 build/ 本地脚本丢失。
  2. 在发布检查里增加完整更新 smoke:
    • 构建后进入 build/SD-Trainer-Portable/SD-Trainer
    • 验证 .git、remote、shallow 状态、当前版本。
    • 模拟运行 update/update_sd_trainer.bat --nopause 或提供可测试模式。
    • 验证根 launcher 被刷新。
  3. build_portable.ps1 增加失败即中止的 .git 嵌入校验:缺 .git/HEAD、remote 不对、非 shallow 或体积异常都 fail。
  4. 为 Update 脚本增加自动化测试/静态测试,防止裸 git pull、覆盖用户目录、子模块失败阻断主更新等回归。
  5. 更新 Release checklist:没有通过 Portable 更新门禁不得发布 7z。
  6. 在 Release 说明中明确区分:Git 版整合包可用 Update-SD-Trainer.bat;无 .git 旧包只能下载新 7z。

验收标准

  • powershell -ExecutionPolicy Bypass -File <portable-release-test> -PortableRoot build/SD-Trainer-Portable -ArchivePath build/SD-Trainer-vX.Y.Z.7z 全 PASS。
  • CI 或本地 release 脚本能在缺 .git、裸 git pull、子模块缺失、用户目录覆盖风险时失败。
  • 新发布包内双击 Update-SD-Trainer.bat 不再出现“不是 git 仓库”。
  • 从 v2.6.0 起,整合包更新机制不再依赖人工补 .git 或手工 checklist。

优先级

P0 / release-blocker

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions