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

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

merged 3 commits into from
Nov 23, 2019

Conversation

SamirTalwar
Copy link
Contributor

Currently, if you run with project.git = true on a repository with symbolic links, we get an IOException.

No idea how to write a unit test for this (can't find any coverage for ScalafmtRunner). If it's OK to move this behavior into GitOps::lsTree, then it becomes easier to test. Please let me know!

Full stack trace when running with version 2.2.2:

Exception in thread "main" java.io.IOException: Is a directory
        at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
        at sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:46)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
        at sun.nio.ch.IOUtil.read(IOUtil.java:197)
        at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:159)
        at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
        at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:109)
        at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
        at java.nio.file.Files.read(Files.java:3105)
        at java.nio.file.Files.readAllBytes(Files.java:3158)
        at org.scalafmt.util.FileOps$.readFile(FileOps.scala:57)
        at org.scalafmt.util.FileOps$.readFile(FileOps.scala:48)
        at org.scalafmt.cli.InputMethod$FileContents.readInput(InputMethod.scala:44)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.handleFile(ScalafmtDynamicRunner.scala:83)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$4(ScalafmtDynamicRunner.scala:55)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$4$adapted(ScalafmtDynamicRunner.scala:49)
        at scala.collection.immutable.List.foreach(List.scala:392)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$3(ScalafmtDynamicRunner.scala:49)
        at scala.util.control.Breaks.breakable(Breaks.scala:42)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.run(ScalafmtDynamicRunner.scala:49)
        at org.scalafmt.cli.Cli$.run(Cli.scala:96)
        at org.scalafmt.cli.Cli$.mainWithOptions(Cli.scala:69)
        at org.scalafmt.cli.Cli$.main(Cli.scala:58)
        at org.scalafmt.cli.Cli.main(Cli.scala)

Copy link
Collaborator

@poslegm poslegm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this fix!

@SamirTalwar
Copy link
Contributor Author

I forgot to explain why I changed f.toFile.delete() to deleteTree(f). The former wasn't actually deleting the directory (because it wasn't empty), it was just returning false, resulting in a lot of leftover temporary files. The latter actually deletes the files.

@poslegm poslegm merged commit 1d96ec1 into scalameta:master Nov 23, 2019
@SamirTalwar
Copy link
Contributor Author

Cheers! Looking forward to v2.2.3!

@SamirTalwar SamirTalwar deleted the git-ls-files-with-symbolic-links branch November 25, 2019 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants