Description
The subcommands lint and format have the option --follow-symlinks. However, although it can follow absolute symlinks, it can't follow relative symlinks.
Steps to reproduce
$ mkdir symlink-test
$ cd symlink-test/
$ echo 'let foo:Int=0' > .foo.swift
$ ln -s .foo.swift bar.swift
$ swift format dump-configuration > .swift-format
$ cd ..
$ swift format lint -rs --follow-symlinks symlink-test/
<unknown>: error: Unable to open .foo.swift: file is not readable or does not exist
If the current working directory is the symlink's directory, it works.
$ cd symlink-test
$ swift format lint -rs --follow-symlinks .
.foo.swift:1:9: warning: [Spacing] add 1 space
.foo.swift:1:12: warning: [Spacing] add 1 space
.foo.swift:1:13: warning: [Spacing] add 1 space
It's because the following line is using relativeTo: workingDirectory.
|
URL(fileURLWithPath: relativePath, isDirectory: false, relativeTo: workingDirectory) |
Environment
- swift-format (bundled in Swift 6.0.1 toolchain)
- Debian 12 (aarch64)
Description
The subcommands
lintandformathave the option--follow-symlinks. However, although it can follow absolute symlinks, it can't follow relative symlinks.Steps to reproduce
If the current working directory is the symlink's directory, it works.
It's because the following line is using
relativeTo: workingDirectory.swift-format/Sources/SwiftFormat/Utilities/FileIterator.swift
Line 152 in 8068ff7
Environment