Skip to content

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

Open
@adonovan

Description

@adonovan

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.RefactoringIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions