Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topiary follows symlinks and "reifies" them, if it makes any changes #834

Open
Xophmeister opened this issue Jan 16, 2025 · 0 comments
Open

Comments

@Xophmeister
Copy link
Member

Xophmeister commented Jan 16, 2025

Describe the bug
If topiary format is run in a directory that contain symlinks to files that need formatting, then Topiary will format the contents of the target and then replace the symlink with that formatted target (i.e., as a regular file).

To Reproduce

$ mkdir test
$ echo '  {  "foo":   "bar"} ' > test/foo.json
$ ln -s foo.json test/bar.json
$ ls -l test
total 4
lrwxrwxrwx 1 chris users  8 Jan 16 10:13 bar.json -> foo.json
-rw-r--r-- 1 chris users 22 Jan 16 10:13 foo.json
$ topiary format test
$ ls -l test
total 8
-rw------- 1 chris users 17 Jan 16 10:14 bar.json
-rw------- 1 chris users 17 Jan 16 10:14 foo.json

Expected behavior
Two options, perhaps controllable via a command line option:

  1. Skip over symlinks (default)
  2. Format any symlinks' targets, leaving the symlink intact

Environment

  • OS name + version: NixOS 24.11
  • Version of the code: 0.5.1

Additional context
A similar problem happens with hardlinks; that is, the link is broken. Unlike the symlink case, I'm not quite sure how this can be fixed.

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

No branches or pull requests

1 participant