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

x/tools/gopls: rename applies duplicate edits to a file with aliases (symlinks) #59550

Open
adonovan opened this issue Apr 11, 2023 · 0 comments
Labels
gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Apr 11, 2023

The kubernetes repo has multiple submodules (k8s.io/xyz), each with a replace directive in the main module that maps them to ./staging/xyz. The vendor directory contains symbolic links vendor/xyz to ../staging/xyz. This means files and directories in staging have aliases such vendor/k8s.io/kubectl -> ../../staging/src/k8s.io/kubectl.

I have observed that some gopls renamings cause the same edits to be applied to both aliases of the same file. If the renaming is length-preserving, this is harmless, but otherwise a renaming from A to AB results in ABB, with a repeated suffix. (Presuambly a renaming that shortened would be even more destructive.)

We need to merge edits not just based on URI equivalence (as we do already), but based on the file system's notion of equivalence, using os.SameFile or robustio.FileID.

(See also https://go.dev/cl/457615, which did the same thing for the go/analysis -fix logic.)

@adonovan adonovan self-assigned this Apr 11, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 11, 2023
@gopherbot gopherbot added this to the Unreleased milestone Apr 11, 2023
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.12.0 Apr 11, 2023
@adonovan adonovan added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 11, 2023
@findleyr findleyr modified the milestones: gopls/v0.12.0, gopls/v0.13.0 May 22, 2023
@adonovan adonovan added the Refactoring Issues related to refactoring tools label Aug 31, 2023
@adonovan adonovan modified the milestones: gopls/v0.14.0, gopls/backlog Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants