Skip to content

Set the rootDir as / instead of // if the project is in the root of the filesystem#732

Merged
nedtwigg merged 2 commits intodiffplug:mainfrom
rudolfv:fix_cached_endings_root_path
Nov 16, 2020
Merged

Set the rootDir as / instead of // if the project is in the root of the filesystem#732
nedtwigg merged 2 commits intodiffplug:mainfrom
rudolfv:fix_cached_endings_root_path

Conversation

@rudolfv
Copy link
Copy Markdown

@rudolfv rudolfv commented Nov 13, 2020

This PR is to fix a bug if a gradle project is in the root of a filesystem. Normally this would not be an issue as projects would are generally not at the root, but in the case of a Docker or other container, the situation could arise:

	Caused by: java.lang.IllegalArgumentException: Expected '/src/main/java/com/acme/MyApplication.java' to start with '//'
		at com.diffplug.spotless.FileSignature.subpath(FileSignature.java:203)
		at com.diffplug.spotless.extra.GitAttributesLineEndings$CachedEndings.endingFor(GitAttributesLineEndings.java:126)
		at com.diffplug.spotless.extra.GitAttributesLineEndings$RelocatablePolicy.getEndingFor(GitAttributesLineEndings.java:95)
		at com.diffplug.spotless.Formatter.computeLineEndings(Formatter.java:211)
		at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:203)
		at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:188)
		at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:71)
		at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:57)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I've read the instructions about adding to the CHANGES.md file, but I don't see a -SNAPSHOT section. I did see the below however, so I presume it is no longer necessary?

@nedtwigg
Copy link
Copy Markdown
Member

Thanks for the fix!

If you update each of the changelogs (root, gradle, and maven) along these lines:

## [Unreleased]
### Fixed
* Fixed a bug which occurred if the root directory of the project was also the filesystem root ([#732](https://github.com/diffplug/spotless/pull/732))

then I'll push the release button.

@rudolfv
Copy link
Copy Markdown
Author

rudolfv commented Nov 16, 2020

Thanks for the update, @nedtwigg! I have made the requested changelog changes.

@nedtwigg nedtwigg merged commit 23f8d69 into diffplug:main Nov 16, 2020
@nedtwigg
Copy link
Copy Markdown
Member

Published in plugin-gradle 5.8.2 and plugin-maven 2.6.1.

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