Repository navigation
docs: 升级片段 stash 顺序与退出码修复 - #17
Merged
Merged
Conversation
[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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修什么
PR #16 判决(
Shared/Transfers/zce-pr16-5f12601c/verdict.md)的两项:git stash push后备份——stash 会把工作区退回旧提交内容,备份抓到的是没有本地编辑的旧版;恢复旧版后git stash pop又因同名文件冲突退出 1,本地编辑压在 stash 里、工作区却是旧内容。现改为:先备份含本地编辑的当前文件(mktemp 独立目录沿用),再 stash/拉取,成功后从本次备份恢复;git stash pop指引删除(编辑已在备份里,stash 只是给上游同步让路,确认升级后 drop 即可)。false而非exit 1(片段是粘贴进交互 shell 的,exit会把整个 shell 关掉);只保留 AGENTS.md(无 CLAUDE.md)的克隆按 if 守卫跳过缺失文件,成功场景退出 0。中英双版同步修改。
验证(隔离仓库仿真,逐条实跑)
# MY LOCAL EDIT完整回到工作区、两份指南以未跟踪文件恢复、退出码 0、stash 只剩冗余副本(无冲突);git stash pop完好找回;node scripts/sync-doc-version.mjs --check通过。纯文档改动,不动 lib。