diff --git a/CHANGES.md b/CHANGES.md index 14facc6c1a..344c97b999 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Fixed * ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)). * prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)). +* fixed error when running on root of windows mountpoint ([#760](https://github.com/diffplug/spotless/pull/760)). ## [2.10.2] - 2020-11-16 ### Fixed diff --git a/lib/src/main/java/com/diffplug/spotless/FileSignature.java b/lib/src/main/java/com/diffplug/spotless/FileSignature.java index d0a8c2881c..59893f26e6 100644 --- a/lib/src/main/java/com/diffplug/spotless/FileSignature.java +++ b/lib/src/main/java/com/diffplug/spotless/FileSignature.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 DiffPlug + * Copyright 2016-2021 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -200,6 +200,9 @@ public static String subpath(String root, String child) { if (child.startsWith(root)) { return child.substring(root.length()); } else { + if (machineIsWin() && root.endsWith("://") && child.startsWith(root.substring(0, root.length() - 1))) { + return child.substring(root.length() - 1); + } throw new IllegalArgumentException("Expected '" + child + "' to start with '" + root + "'"); } } diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 735eecdc9a..9f29756fb2 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -14,6 +14,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * `ratchetFrom` now works with git-submodule ([#746](https://github.com/diffplug/spotless/issues/746)) * ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)). * prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)). +* fixed error when running on root of windows mountpoint ([#760](https://github.com/diffplug/spotless/pull/760)). ## [5.8.2] - 2020-11-16 ### Fixed diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 0e995edf91..3860af5235 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -16,6 +16,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * Fix broken test for spotlessFiles parameter on windows ([#737](https://github.com/diffplug/spotless/pull/737)) * ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)). * prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)). +* fixed error when running on root of windows mountpoint ([#760](https://github.com/diffplug/spotless/pull/760)). ## [2.6.1] - 2020-11-16 ### Fixed diff --git a/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java b/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java index f69d573c04..f2a5d30cef 100644 --- a/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 DiffPlug + * Copyright 2016-2021 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.List; +import org.assertj.core.api.Assertions; import org.junit.Test; public class FileSignatureTest extends ResourceHarness { @@ -79,4 +80,11 @@ private List getTestFiles(final String[] paths) throws IOException { public void testSubpath() { assertThat(FileSignature.subpath("root/", "root/child")).isEqualTo("child"); } + + @Test + public void windowsRoot() { + org.junit.Assume.assumeTrue(FileSignature.machineIsWin()); + String subpath = FileSignature.subpath("S://", "S:/build.gradle"); + Assertions.assertThat(subpath).isEqualTo("build.gradle"); + } }