fix(init): restore first-run overwrite of README/CHANGELOG#17
Conversation
The c6a35cf guard against overwriting customized README.md/CHANGELOG.md on re-runs broke the first-run flow. On the un-initialized template, both the template-facing *.md files AND their *.template.md sources are present — file presence alone can't distinguish "first init" from "re-init with template files reappearing." The guard fired on first init, leaving the template-facing README.md/CHANGELOG.md in place AND leaving CHANGELOG.template.md on disk, which then makes downstream CI read is_template=true and skip every job on the user's brand-new module. Use the existing $templateModuleFolder check as the disambiguator: if {{ModuleName}}/ existed at script start, this is a first run and overwrite is correct; if it didn't, the user already initialized once and is re-running, so preserve any customized destination. Restore -Force on Move-Item since the first-run path now legitimately needs to overwrite the template-facing files. Smoke test on a fresh worktree of main with this fix verifies: - README.md / CHANGELOG.md replaced with module-facing content - README.template.md / CHANGELOG.template.md removed from disk - workflow guard sees is_template=false on the resulting module Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Initialize-Template.ps1 script now tracks initialization state via a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Pull request overview
Restores correct first-run initialization behavior for template repositories by using the presence of the pre-init {{ModuleName}}/ folder to distinguish first init vs re-run, ensuring README/CHANGELOG templates are moved/overwritten appropriately and template marker files don’t survive post-init.
Changes:
- Capture initialization state once (
$wasAlreadyInitialized) based on existence of the{{ModuleName}}/folder. - Restore
Move-Item -ForceforREADME.template.md→README.mdandCHANGELOG.template.md→CHANGELOG.mdon first init, while preserving user files on re-run.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes a regression introduced in c6a35cf (PR #16) that breaks the first-run init flow.
What broke
PR #16's c6a35cf added a "don't clobber on re-run" guard around the README/CHANGELOG
Move-Itemcalls:The intent was to handle CodeRabbit's concern about a re-run with template files reappearing wiping out user-customized content. The bug: on a fresh template both files exist already — the template-facing
README.md(this repo's own README) and the module-facingREADME.template.md(source for the new module). The guard sees the destination present and treats first-init as a re-run, leaving the template-facing files in place AND leaving*.template.mdfiles on disk.Critical knock-on:
CHANGELOG.template.mdsurvives post-init, so PR #16's workflow guard readsis_template=trueon the downstream and skips every CI job on the user's brand-new module — exactly the failure mode PR #16 was meant to prevent.Fix
File presence alone can't disambiguate "first init" from "re-init with template files reappearing." Use the existing
{{ModuleName}}/folder check (already atInitialize-Template.ps1:124) as the disambiguator: if it existed at script start, this is a first run; if it didn't, the user already initialized once and is re-running.-Forceis restored onMove-Itembecause the first-run path now legitimately needs to overwrite the template-facingREADME.md.Verification — fresh-worktree smoke test
Pre-fix run on c8f5586 (post-#16 main) ended with two
WARNINGlines and left*.template.mdfiles on disk. Post-fix run on this branch:Inspecting the resulting worktree:
*.template.mdfiles: none remainingREADME.md: module-facing content (# SmokeTest+ the substituted description)CHANGELOG.md: module-facing Keep-a-Changelog scaffold{{ModuleName}}/removed,SmokeTest/presentCI.yaml(appears 2× as designed: lint + unit-tests)is_template=falsewould be the bash check's result, so downstream CI jobs run normallyTest plan
git worktree --detachof this branch — passes (above).$wasAlreadyInitializedis true and destination exists — by inspection of the conditional.Initialize-Template.ps1— clean.🤖 Generated with Claude Code
Summary by CodeRabbit