Skip to content

Detect windows using os.name rather than line.separator. - #639

Merged
nedtwigg merged 7 commits into
mainfrom
feat/detect-windows
Jul 4, 2020
Merged

nedtwigg merged 7 commits into
mainfrom
feat/detect-windows

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Jul 3, 2020

Copy link
Copy Markdown
Member

Added FileSignature.machineIsWin, which detects the OS using os.name, and replaces the now-deprecated LineEnding.nativeIsWin, which detected the OS using line.separator.

nedtwigg added 2 commits July 3, 2020 15:00
…orm is unreliable. Deprecate `LineEnding.nativeIsWin()`, and add `FileSignature.machineIsWin()`.
…machineIsWin()`. Notably, none of the usages actually cared about line endings, they only cared about paths and default system shells, which indicates that bundling this with `LineEnding` was probably always a bad idea.

@J-N-K J-N-K left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should work in any case and the performance penalty on *nix machines is probably neglegible. Even if you keep the check (probably a !machineIsUnix() would be more clear, since that is essentially what is interesting here) you could keep the File.separatorChar.

Comment thread lib/src/main/java/com/diffplug/spotless/FileSignature.java Outdated
Comment thread lib/src/main/java/com/diffplug/spotless/FileSignature.java Outdated
@nedtwigg

nedtwigg commented Jul 4, 2020

Copy link
Copy Markdown
Member Author

Ooh, I like the File.separatorChar, thanks. We'll have a bugfix release out by Monday, there's one other bug I need to look into.

@nedtwigg

nedtwigg commented Jul 4, 2020

Copy link
Copy Markdown
Member Author

There was a related bug, which was completely clobbering the git-native line endings anyway. Just fixed in previous commit. With these fixes combined, I think we have fixed the problem completely.

@nedtwigg
nedtwigg merged commit b77fef2 into main Jul 4, 2020
@nedtwigg
nedtwigg deleted the feat/detect-windows branch July 4, 2020 21:24
@nedtwigg

nedtwigg commented Jul 5, 2020

Copy link
Copy Markdown
Member Author

Released in plugin-maven 2.0.1 and plugin-gradle 4.5.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