Repository navigation
fix(release-prep): CHANGELOG 占位节在 CRLF 检出上不再静默失效 - #360
Conversation
原实现用 /^(# Changelog\n\n)/ 匹配 CHANGELOG 文件头,而 Windows 检出是 CRLF —— 正则命中
不了,`replace` 退化成空操作,**但脚本照样打印 `✓ … 占位节`**,`git status` 里看不出任何
异常。CI 的 release-prep 工作流跑在 ubuntu(LF)所以从未暴露,只有本机发版会中招——v0.8.13
那次即如此,最后靠人工补的占位节。
改法:规则抽成 dsh-mneme/scripts/changelog-prep.mjs 的纯函数(入口在仓库根、import 即执行,
测不了;与 test-count-sync.mjs 收拢替换规则同一个理由)。
- 行尾 `\r?\n` 两种都吃,插入内容跟随原文件行尾(不混排),带 BOM 也认;
- 匹配不上时返回 {ok:false, reason:"header-not-found"} 而不是静默返回原文,入口据此报错
并 exit 1 —— 绝不假打印成功。
6 条回归测试:LF / CRLF / BOM / 幂等 / 回报契约 / detectEol。变异检验:把正则改回只认 LF、
失败时改回「返回原文」、固定用 LF 插入——三条各自让对应用例变红。
本批新增 6 条用例,双 README 的测试数随之从 1523 用 npm run badge:sync 刷到 1529(6 处), 不手改。
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthrough发布准备脚本现在使用新增的 CHANGELOG 章节插入函数。该函数识别 LF、CRLF 和可选 BOM,处理重复版本及未匹配标题的情况。新增回归测试,并将文档中的测试数量更新为 1529。 ChangesCHANGELOG 发布准备
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The reported version-string issue cannot occur in the release workflow. The change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change improves failure reporting without adding public access or privileges. Release preparation still has existing non-transactional writes and workflow input-handling risks; recovery ownership and dispatch authorization were not established. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
问题
scripts/release-prep.mjs(本机发版 prep 的入口)用/^(# Changelog\n\n)/匹配 CHANGELOG文件头,而 Windows 检出是 CRLF —— 正则命中不了,
replace退化成空操作,但脚本照样打印
✓ dsh-mneme/CHANGELOG.md 占位节,git status里看不出任何异常。CI 的 release-prep 工作流跑在 ubuntu(LF)所以从未暴露,只有本机发版会中招:v0.8.13 那次
就是这样——脚本报成功、实际什么都没写,最后靠人工补的占位节。
复现(实跑证据)
改后在同一棵 CRLF 检出上真跑脚本:
✓ … 占位节且git diff里确实多了 6 行。改法
规则抽成
dsh-mneme/scripts/changelog-prep.mjs的纯函数——入口在仓库根、import即执行,测不了;与
test-count-sync.mjs收拢替换规则是同一个理由(规则收在共用模块里才测得到,也才不会两处各写一份)。
\r?\n两种都吃,插入内容跟随原文件行尾(不混排),带 BOM 也认;{ok:false, reason:"header-not-found"}而不是静默返回原文——入口据此报错并
exit 1,绝不假打印成功。验证
detectEol):全量1529 tests / 1528 pass / 0 fail / 1 skip
check-sync:src ↔ lib 一致(52 文件)node scripts/release-prep.mjs 9.9.9→ 这次真的写进去了(git diff+6 行)✗ …(reason=header-not-found),exit 1,CHANGELOG 一个字节没动顺带
新增 6 条用例后,双 README 的测试数由
badge:sync从 1523 刷到 1529(6 处)。没做的
第 4 步(双 README 版本表占位行)是死代码——两张表早就不存在。它不算静默失败(脚本会
如实打印
无版本表格行,跳过),所以本批不动:要么将来表格回来还有用,要么该单独判断要不要删,混进来只会让 diff 变难审。
Summary by CodeRabbit