fix(filemerge): preserve symlinked config files#1077
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughWriteFileAtomic and readComparableFile now resolve symlinks before comparing and renaming, and readManagedFile now follows symlinks instead of rejecting them. The tests were updated to verify preserved links, target updates, broken-link behavior, and Windows symlink privilege skips. ChangesSymlink resolution support
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/components/filemerge/writer.go`:
- Around line 118-134: The resolveExistingSymlink helper in writer.go treats
dangling symlinks as hard errors, causing WriteFileAtomic to abort. Update
resolveExistingSymlink (and the WriteFileAtomic path that uses it) to explicitly
handle os.ModeSymlink targets that are broken by either treating them as
create-through paths or replacing the symlink with a regular file, and keep the
behavior consistent for all symlink-managed paths.
In `@internal/components/uninstall/cleaners_test.go`:
- Around line 286-308: Add a regression test in
TestReadManagedFile_FollowsSymlink coverage for a broken symlink case, using
readManagedFile and the rewriteJSONFile/os.IsNotExist contract. Create a
symlink, remove its target, then verify readManagedFile returns an error that
still satisfies os.IsNotExist through the PathError/ENOENT wrapping path, so
future changes to filepath.EvalSymlinks error handling don’t break the no-op
behavior in service.go.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2a5b3c67-fb38-474c-94f8-6dfc09e000e7
📒 Files selected for processing (4)
internal/components/filemerge/writer.gointernal/components/filemerge/writer_test.gointernal/components/uninstall/cleaners.gointernal/components/uninstall/cleaners_test.go
|
Addressed the CodeRabbit feedback in
Validation:
The PR remains under the 400-line review budget: 215 insertions / 16 deletions. |
Linked Issue
Closes #306
PR Type
Summary
Changes
internal/components/filemerge/writer.gointernal/components/filemerge/writer_test.gointernal/components/uninstall/cleaners.gointernal/components/uninstall/cleaners_test.goTest Plan
go test ./internal/components/filemerge ./internal/components/uninstallgit diff --checkgo test ./...— currently fails ininternal/clion this machine becauseTestEngramPathGuidanceDefaultexpectsgo/bin, while Go is installed under asdf (/home/fjpalacios/.asdf/installs/golang/1.25.5/bin). Packages touched by this PR pass.Follow-up
The interactive/configurable uninstall symlink policy is intentionally deferred to #1078 so this bugfix stays under the 400-line review budget.
Notes
Maintainer note: I cannot add
type:bugfrom this fork, so the PR still needs exactly onetype:*label added by someone with label permissions.Summary by CodeRabbit
Bug Fixes
Tests