fix(archive): 未追踪 change 目录归档不再 pathspec fatal - #33
Merged
Merged
Conversation
archive execute 在移动目录后无条件 git add 旧路径;当 change 目录从未入 commit(如 release 文件清单遗漏了 change 目录本身)时,旧路径无物可加, pathspec fatal 把归档卡在半落状态(目录已移走、INDEX 已重建、commit 未落)。 修复:rename 前用 git ls-files 探测旧目录是否被追踪,仅追踪时才把旧路径 加入暂存表;未追踪时只暂存 INDEX 与 archive 新路径。附未追踪场景回归测试。
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.
现场复现
在 x.wuh.site 仓库对从未入 commit 的 change 目录执行
archive execute:目录被移动、INDEX 已重建,随后 CLI 在收尾git add处 fatal:归档卡在半落状态(旧路径已移走、新路径未追踪、commit 未落),只能人工补提交。
根因
lib/domains/archive.mjs的 execute 在renameSync之后无条件git add旧路径。旧目录被追踪时该 add 负责暂存删除(必要);但 change 目录从未被追踪时(本例:release 文件清单遗漏了 change 目录本身),旧路径既不存在也无索引条目,pathspec 直接 fatal。修复
renameSync前用git ls-files -- <old>探测旧目录是否被追踪,仅追踪时才把旧路径加入暂存表;未追踪时只暂存INDEX.md与 archive 新路径。被追踪场景行为不变(原用例继续通过)。测试
--test-name-pattern "archive execute"下两用例均过