Skip to content

docs: 升级片段 stash 顺序与退出码修复 - #17

Merged
kyomarshal merged 1 commit into
mainfrom
fix/pr16-upgrade-order
Nov 27, 2026
Merged

kyomarshal merged 1 commit into
mainfrom
fix/pr16-upgrade-order

Conversation

@kyomarshal

Copy link
Copy Markdown
Collaborator

修什么

PR #16 判决(Shared/Transfers/zce-pr16-5f12601c/verdict.md)的两项:

  1. [Medium] stash 顺序错误:旧片段先 git stash push 后备份——stash 会把工作区退回旧提交内容,备份抓到的是没有本地编辑的旧版;恢复旧版后 git stash pop 又因同名文件冲突退出 1,本地编辑压在 stash 里、工作区却是旧内容。现改为:先备份含本地编辑的当前文件(mktemp 独立目录沿用),再 stash/拉取,成功后从本次备份恢复;git stash pop 指引删除(编辑已在备份里,stash 只是给上游同步让路,确认升级后 drop 即可)。
  2. [Low] 退出码:拉取失败显式非零——用 false 而非 exit 1(片段是粘贴进交互 shell 的,exit 会把整个 shell 关掉);只保留 AGENTS.md(无 CLAUDE.md)的克隆按 if 守卫跳过缺失文件,成功场景退出 0。

中英双版同步修改。

验证(隔离仓库仿真,逐条实跑)

  • 场景A:pre-chore: untrack local AGENTS.md/CLAUDE.md and split Jev config reference from SKILL.md #14 克隆 + AGENTS.md 未提交本地编辑,原样跑片段 → HEAD 前进到 untrack 提交、# MY LOCAL EDIT 完整回到工作区、两份指南以未跟踪文件恢复、退出码 0、stash 只剩冗余副本(无冲突);
  • 场景B:远端不可达 → 退出码 1、什么都不恢复、HEAD 不动、本地编辑经 git stash pop 完好找回;
  • 场景C:只保留 AGENTS.md 的克隆(CLAUDE.md 未提交删除)→ 升级成功、退出码 0、不误恢复 CLAUDE.md;
  • node scripts/sync-doc-version.mjs --check 通过。纯文档改动,不动 lib。

[Medium] The #16 snippet stashed BEFORE backing up: stash reverts the
worktree to the old committed content, so the backup captured the
pristine version and the user's local edits were never restored — worse,
a later git stash pop then conflicts on the same filenames and exits 1.
The order is now backup-with-edits FIRST, stash second (it only clears
the upstream sync — nothing left to pop, drop it when happy).

[Low] The failure branch exits non-zero via 'false' instead of 'exit 1'
(which would kill the interactive shell the snippet is pasted into);
the per-file restore tests use a guarded if so a clone keeping only
AGENTS.md exits 0 instead of failing on the missing CLAUDE.md test.

Verification (simulated pre-#14 clones): with uncommitted guide edits
the full snippet restores the edits verbatim as untracked files and
advances HEAD, stash holding only the redundant copy; an unreachable
remote exits 1, restores nothing, edits recoverable via stash pop; a
clone keeping only AGENTS.md upgrades with exit 0.
sync-doc-version --check passes.
@kyomarshal
kyomarshal merged commit 4172fca into main Nov 27, 2026
3 checks passed
@kyomarshal
kyomarshal deleted the fix/pr16-upgrade-order branch November 27, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant