Spotless does not respect line endings on Windows 10
See original GitHub issueWe have lineEndings = 'unix';
specified in our Spotless config, but it appears to not be respected in Windows 10 or Windows Server 2016.
Here are the instructions to reproduce:
I ran ./gradlew spotlessApply on the Windows 10 machine using git bash this is what has happened. NOTE: I started the below steps on a fresh git clone of the open side. [Steps:
- git clone https://git-wip-us.apache.org/repos/asf/incubator-geode.git open
- cd open
- git checkout -b develop origin/develop]
Step 1. ./gradlew clean build -Dskip.tests=true
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ‘:geode-core:spotlessJavaCheck’. Format violations were found. Run ‘gradlew spotlessApply’ to fix them.
geode-core\src\main\java\org\apache\geode\internal\statistics\StatArchiveReader.java
geode-core\src\test\java\org\apache\geode\cache\query\dunit\PdxLocalQueryVersionedClassDUnitTest.java
geode-core\src\test\java\org\apache\geode\internal\cache\execute\ClientServerFunctionExecutionDUnitTest.java
geode-core\src\test\java\org\apache\geode\internal\cache\functions\TestFunction.java
geode-core\src\test\java\org\apache\geode\internal\statistics\StatArchiveWithMissingResourceTypeRegressionTest.java
Step 2: ./gradlew spotlessApply
BUILD SUCCESSFUL
Total time: 12.728 secs
Step 3: git status
modified: geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java modified: geode-core/src/test/java/org/apache/geode/cache/query/dunit/PdxLocalQueryVersionedClassDUnitTest.java modified: geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java modified: geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java modified: geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
Step 4 : git add . warning: LF will be replaced by CRLF in geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/cache/query/dunit/PdxLocalQueryVersionedClassDUnitTest.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java. The file will have its original line endings in your working directory.
Step 5: git status On branch develop Your branch is up-to-date with ‘origin/develop’. nothing to commit, working tree clean
Step 6: ./gradlew clean build -Dskip.tests=true BUILD SUCCESSFUL
Total time: 5 mins 28.64 secs
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
I thought Git only mucked with line endings when you add files, I didn’t know it actually did that on checkout. Thank you so much for your explanation.
If there’s any truth in the world, it’s this: git is always mucking with your line endings 😉
Everything I said above can be changed based on a variety of more obscure git settings files spread across your machine-global config, your home directory, and your repo. But
.gitattributes
blasts all that and defines the truth unambiguously, which is why the README says to just make one and ignores the rest.