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

Remove irregular files, including symbolic links, from git ls-files. #1559

Merged
merged 3 commits into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ trait ScalafmtRunner {
val files = options.fileFetchMode match {
case m @ (GitFiles | RecursiveSearch) =>
val fetchFiles: AbsoluteFile => Seq[AbsoluteFile] =
if (m == GitFiles) options.gitOps.lsTree(_)
else FileOps.listFiles(_)
if (m == GitFiles)
options.gitOps
.lsTree(_)
.filter(file => FileOps.isRegularFile(file.jfile))
SamirTalwar marked this conversation as resolved.
Show resolved Hide resolved
else
FileOps.listFiles(_)

options.files.flatMap {
case d if d.jfile.isDirectory => fetchFiles(d).filter(canFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ object FileOps {
if (file.isAbsolute) file
else new File(workingDir, file.getPath)

def isRegularFile(file: File): Boolean =
Files.isRegularFile(file.toPath)

def listFiles(path: String): Vector[String] = {
listFiles(new File(path))
}
Expand Down