fix(compact): preserve Go files with //go:embed directives unchanged#88
fix(compact): preserve Go files with //go:embed directives unchanged#88greynewell merged 2 commits intomainfrom
Conversation
context.Background() ignores Cobra's command context, meaning Ctrl+C had no effect on in-flight API calls in audit, share, and restore. Derive all timeouts from cmd.Context() so cancellation propagates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
//go:embed must immediately precede its variable declaration; moving it to the top of the file (as scanGoDirectives was doing) detaches it from the variable, causing compilation failures at embed time. Fix: return the source unchanged when //go:embed is present, and remove //go:embed from scanGoDirectives (only //go:build, // +build, and //go:generate belong at the file top). Add a test to prevent regression. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughThis PR makes two main changes: (1) Updates context handling in three CLI commands (audit, restore, share) to use the Cobra command's lifecycle context instead of standalone background contexts, affecting when operations are canceled, and (2) Modifies Go source compaction to detect and preserve Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
compactGowas including//go:embedin the list of directives recovered after stripping comments//go:build/// +build(which belong at the file top),//go:embedmust immediately precede its variable declaration_ "embed"import becomes unused)//go:embedis present; remove it fromscanGoDirectivesTestCompactGoPreservesEmbedFilesTest plan
go test ./internal/compact/...passes including new testgo build ./...passessupermodel compacton a Go file with//go:embedreturns it unchanged🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
New Features