Closed
Description
If you are submitting a bug, please include the following:
- summary of problem
- spotless check can not checkout the file with cr(\r) lineSeparator
- gradle or maven version
- maven with 3.8
- spotless version
- 2.22.4
- operating system and version
- macos
- copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.22.4</version>
<configuration>
<formats>
<format>
<includes>
<include>*.java</include>
<include>*.xml</include>
</includes>
<trimTrailingWhitespace/>
<endWithNewline/>
<encoding>UTF-8</encoding>
<indent>
<spaces>true</spaces>
<spacesPerTab>4</spacesPerTab>
</indent>
</format>
</formats>
<java>
<encoding>UTF-8</encoding>
<googleJavaFormat>
<version>1.15.0</version>
<style>AOSP</style>
</googleJavaFormat>
<removeUnusedImports/>
</java>
<encoding>UTF-8</encoding>
<lineEndings>UNIX</lineEndings>
</configuration>
</plugin>
Activity
nedtwigg commentedon May 5, 2022
There are two standard line endings in use today:
\n
\r\n
On Mac OS Classic (last actively developed 20 years ago around Y2K) there was a
\r
only line ending convention. To my knowledge, that mode is completely unsupported by git.If you want to add a
MAC_CLASSIC
line ending, I'd be happy to merge it.The tricky part is that this method currently assumes it is getting
\r\n
or\n
, and then it promises to return\n
only. You'll have to update it to detect files with\r
but no\n
, and then replace\r
with\n
.spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 138 to 147 in 4230476
Then these methods would need to get updated too (perhaps other places too, but I think this is most of it).
spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 40 to 45 in 4230476
spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 72 to 77 in 4230476
spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 97 to 98 in 4230476
spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 114 to 120 in 4230476
[-]spotless check can not checkout the file with cr(\r) lineSeparator ?[/-][+]add support for MAC_CLASSIC (\r only)[/+]DemonJun commentedon Jun 20, 2022
Here I don't understand, if input is endWith '\n', it must go to the else block? Is this necessary?
DemonJun commentedon Jun 20, 2022
After adding the MAC_CLASSIC conversion, I think it should look like this.
nedtwigg commentedon Jun 30, 2022
Released in
plugin-gradle 6.8.0
andplugin-maven 2.23.0
, thanks to @DemonJun.