Skip to content

fix: handle symlinks in WriteFileAtomic#307

Closed
utafrali wants to merge 1 commit into
Gentleman-Programming:mainfrom
utafrali:fix/issue-306-error-in-the-sync-uninstall-commands-for
Closed

fix: handle symlinks in WriteFileAtomic#307
utafrali wants to merge 1 commit into
Gentleman-Programming:mainfrom
utafrali:fix/issue-306-error-in-the-sync-uninstall-commands-for

Conversation

@utafrali
Copy link
Copy Markdown
Contributor

Linked Issue

Closes #306

PR Type

  • bug fix
  • feature
  • refactor
  • docs
  • other

Summary

Was hitting errors when writing to symlinked config files, which breaks dotfile managers like stow and chezmoi. The issue was WriteFileAtomic was treating symlinks as regular files and potentially replacing them instead of updating the target.

Added symlink resolution so we write to the actual file and preserve the symlink.

Changes

File Description
internal/components/filemerge/writer.go Added readComparableFile() helper to resolve symlinks, updated WriteFileAtomic() to follow symlinks before reading/writing
internal/components/filemerge/writer_test.go Added TestWriteFileAtomic_PreservesSymlink to verify writes update the target while symlinks are preserved

Test Plan

Added TestWriteFileAtomic_PreservesSymlink which creates a symlink, writes through it, and verifies the target file is updated while the symlink stays intact. Existing tests pass.

@utafrali utafrali force-pushed the fix/issue-306-error-in-the-sync-uninstall-commands-for branch from 65fcd71 to c9984a8 Compare April 14, 2026 20:42
@fjpalacios
Copy link
Copy Markdown

I also use Stow to sync my dotfiles, and this error is a real headache. Thanks for the PR, and I hope it gets reviewed soon.

Copy link
Copy Markdown
Contributor

@Alan-TheGentleman Alan-TheGentleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a useful filesystem bugfix, but it needs the standard contribution gates before review.

Please add the required type:bug label, confirm the approved issue link, and refresh CI against current main.

@Alan-TheGentleman
Copy link
Copy Markdown
Contributor

Thanks for the contribution. I’m closing this PR because it does not link to an issue with status:approved, which is required by this repo before PR work can proceed.

Please follow the project process:

  1. Open or update the relevant issue with the proposed change and reproduction/context.
  2. Wait for a maintainer to add status:approved.
  3. Open a fresh PR that includes Closes #<issue> and exactly one type:* label.

This keeps review scope clear and prevents CI/process failures.

@Alan-TheGentleman
Copy link
Copy Markdown
Contributor

Alan-TheGentleman commented May 26, 2026

Hey, thanks for contributing!

Per CONTRIBUTING.md, every PR needs an issue linked with status:approved before it can be reviewed — and this PR doesn't satisfy that gate (the linked issue doesn't exist, is closed, or isn't approved).

Closing for now. To pick the work back up:

  1. Open (or find) an issue describing the change
  2. Wait for a maintainer to apply status:approved
  3. Reopen this PR or open a new one with Closes #<issue> in the body

Sorry for the friction — the gate is automated, there's no workaround. Come back when it's ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in the sync/uninstall commands for when using symlinks for dotfiles

3 participants